First code will work, if you use PBPL, because result is stored into temporally long variable.
That is same as this
Temp VAR LONG
BVal VAR BYTE
BVal = 0
Temp = BVal - 1
If Temp < 0 THEN Negative
First code will work, if you use PBPL, because result is stored into temporally long variable.
That is same as this
Temp VAR LONG
BVal VAR BYTE
BVal = 0
Temp = BVal - 1
If Temp < 0 THEN Negative
That's what I thought, makes sense, thanks!
I haven't yet used PBPL in any project. I tried on my servo project but the "cost" of compiling with PBPL was too high so I managed without it.
/Henrik.
Although answered by pedja089, yes Henrik. It will work in either your example if you compile with PBPL. But as you said, the cost is high. So if you only need a comparisson, you can find other ways to do it just fine.
Ioannis
I think this won't work...
Because BVal is byte, and byte is always unsigned. So it can't be lower than 0. Correct me if I'm wrong...Code:BVal VAR BYTE BVal = 0 BVal = BVal - 1 If BVal < 0 THEN Negative
It WILL work only if you use PBPL because the result is stored temporarily in a long variable. This variable is checked, so yes it will work fine.
For more info check the new PBP manual that clarifies the case.
Ioannis
Isn't result stored in BVal in this example?
BVal = BVal - 1
Result in BVal is 255(Checked with debugger). And because BYTE is unsigned it can't be negative. Program won't jump to negative.
Then tried: If BVal - 1< 0 THEN Negative
Then is negative.
I really can't see how value in this statement is stored at end in temp var BVal = BVal - 1.
That code is same as:
Temp=BVal - 1
BVal =Temp
So we loose sing when value is passed to BVal.
I'm done my homework, now you do yours![]()
Bookmarks