A simple logic question

Status
Not open for further replies.

Vizier87

Active Member
Hi guys,

Is this correct?

Code:
case ('p'||'P'):
         digit(0xce);
         break;

Basically, what I'm trying to do is to display the same thing when I enter either a "p" or "P".

This goes like Display("PpPpP") and it goes about showing the same characters. However when used this, it doesn't work and the 7-segment display just omitted the entire character.

However, if it is like this:
Code:
case ('p'):
         digit(0xce);
         break;
It works just fine but I have to put only a small "p" in my string.

What did I miss?

Thanks.
Vizier87.
 
Thanks NG. I'll try that out when I get back. Mind telling me what's wrong with the previous one though?
 
Thanks NG. I'll try that out when I get back. Mind telling me what's wrong with the previous one though?

"||" is a boolean operation which evaluates to 0 if both operands are 0, or 1 otherwise.

'p'||'P' evaluates to 1

C:
case 'p'||'P':

is the same as:

C:
case 0x01:
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…