expected behaviour or bug?

BlitzMax Forums/BlitzMax Programming/expected behaviour or bug?

Russell(Posted 2008) [#1]
The negate operator ('-') doesn't seem to work with constants of unsigned type. For example:
Const con1:Short = 1
Local con2:Short = 1

Print -con1    ' Prints 65535
Print -con2    ' Prints -1 as expected (variables not affected it seems)

Took me forever to track down this as the culprit in some code I have!
I know you will say that I should use signed constants if the largest value will fit into it, but coming from the good ol' efficient programming days I used the smallest type that would fit the bill.

Still, it makes me wonder why constants behave this way and not variables...

Russell

p.s. I didn't put this in Bug Reports because I'm not sure if this is expected behaviour for an unsigned constant or not.


xlsior(Posted 2008) [#2]
I know you will say that I should use signed constants if the largest value will fit into it, but coming from the good ol' efficient programming days I used the smallest type that would fit the bill.


As far as efficiency is concerned: Apparently Integers are the fastest in BlitzMax.


Czar Flavius(Posted 2008) [#3]
They are, and if you're trying to be efficient you've not done very well, where's the Bytes??