(Urgent) How can I tell the basic stamp to define negative number??
Leung Cheuk Fung
Posts: 5
During receive data from sensor,I found that basic stamp can not define negatives and read as positive number. How can I modify the code to define negative number??
Comments
IF (value & $800) > 0 THEN value = value | $F000
This checks the sign bit of the 12-bit value. If it's non-zero, the value is negative, so the sign bit is extended to make a 16-bit 2's complement negative value. If you sensor deals with some other kind of value, you'd have to do something appropriate for that.