Spin negative numbers??
TJHJ
Posts: 243
Ok so my math my not be the greatest but how can I allow and use negative numbers?
Currently if I use byte variables and store
If byte variables are used this gives 255
If word variables are used this gives 65544
I want the answer to be -1.... Well I want a lot of things but Ill start small.
The problem I think lies in telling the prop signed or unsigned number, but I cant seem to find a command to do this.
Thanks as always
TJ
Currently if I use byte variables and store
X := 128 ' Fixed Value NewX := 129 ' Updating Value but per example 129 works. Diffx := X-Newx
If byte variables are used this gives 255
If word variables are used this gives 65544
I want the answer to be -1.... Well I want a lot of things but Ill start small.
The problem I think lies in telling the prop signed or unsigned number, but I cant seem to find a command to do this.
Thanks as always
TJ
Comments
(byte_var << 24 ~> 24) sign extends a byte in an expression.
(word_var << 16 ~> 16) sign extends a word in an expression.
-Phil
Post Edited (Phil Pilgrim (PhiPi)) : 6/24/2008 9:13:35 PM GMT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Paul Baker
Propeller Applications Engineer
Parallax, Inc.
edit: beat me to it [noparse][[/noparse]8^)
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
lonesock
Piranha are people too.
-Phil
Cool, Sign operator should make this work, thanks again all.