At the very beginning I have
Code:rows = 8 remaining = (0 - rows)
At the very beginning I have
Code:rows = 8 remaining = (0 - rows)
Couple problems here.
As Sayzer pointed out ... "...Keep in mind that all of the math and comparisons in PBP are unsigned."
This means that
if i < 0 then
will always evaluate to FALSE. And the FOR loop will always terminate before executing anything because -8 is really 248 in PBP math (assuming byte vars).
You'll need to find positive numbers to work with.
DT
Or testing the MSB of the variable. If 1=> negative if 0=>positive.
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
I make load indicator with loadcell, i using pic 16f877. For 16 bit adc i using cd4066 , value from -65535 to +65535 with peak hold
I setup - reading
B0 var word ( reading of adc )
B1 var word
B2 var byte
main: if B0 > 0 then ( B1 = B0 ) and ( B2 = 43 ) ' 43 is + sign
if B0 < 0 then B1 = ( 65535 - B0 ) and ( B2 = 45 ) '45 is - sign
lcdout $fe,1
lcdout " Load ", B2, dec5 B1
Originally Posted by precision
Hi precision,
Your IF statements are not precise
You should correct them as follows.
Code:if B0 > 0 then B1 = B0 B2 = 43 endif if B0 < 0 then B1 = 65535 - B0 B2 = 45 endif B0 never equals to zero?
This is actually the idea of assigning a flag that will indicate negative status.
That is why I asked above, will you use this negative number in a math operation.
You can have a flag, like NegFlag=1 meaning you have the negative value, and NegFlag=0 meaning positive value.
If of course it can be useful in your case.
"If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte
Bookmarks