If I subtract 1 from a variable that currently has a value of 0 what will the result be? 0? 255? or something else?
Printable View
If I subtract 1 from a variable that currently has a value of 0 what will the result be? 0? 255? or something else?
if it's a BYTE... yes it will be 255.
thanks mister_e
Depends on how you want to look at it.
It can also be -1
Displays -1 on LCDCode:X VAR BYTE
X = 0
X = X - 1
LCDOUT SDEC X
<br>
If any are preceded by an S (for signed), the output will be sent
preceded by a “-“ if the high order bit of the data is set. This allows the
transmission of negative numbers. Keep in mind that all of the math
and comparisons in PBP are unsigned. However, unsigned math can
yield signed results. For example, take the case of B0 = 9 - 10.
The result of DEC B0 would be “255". Sending SDEC B0 would give “-
1" since the high order bit is sent. So with a little trickery, the unsigned
math of PBP can yield signed results.
Thanks Darrel. This second post is because I have always skipped that portion of the manual and done it in hard way. Thanks again.
Can't say that anymore. :DQuote:
I never knew that
Glad to help.
<br>