Frank Heckenbach wrote:
Waldek Hebisch wrote:
Adriaan van Os wrote:
- is there a difference between $FF.. and $0FF.. ?
- is $FF.. signed or not ?
Any comments ?
<snip>
Yes -- so the answers to the questions above are clearly `$FF = $0FF' (BP agrees), and `$FF.. > 0' (it can be stored in a signed or unsigned type, of course, if range permits, but it should never represent a negative value).
Here are the results for MetroWerks CodeWarrior Pascal (where Integer is 16-bits, longint 32-bits and an 64-bits integer type is missing).
Const {positive unless marked negative} k1= $F; k2= $FF; k3= $FFF; k4= $FFFF; {negative} k5= $FFFFF; k6= $FFFFFF; k7= $FFFFFFF; k8= $FFFFFFFF; {negative} h1= $0F; h2= $0FF; h3= $0FFF; h4= $0FFFF; h5= $0FFFFF; h6= $0FFFFFF; h7= $0FFFFFFF; h8= $0FFFFFFFF; {negative}
I think, the motivation is, if "0" defaults to an integer type, why shouldn't $FFFF or $FFFFFFFF ? Personally I believe that, whatever the behaviour, it should be well documented, as this kind of thing could lead to very surprising bugs.
This would imply that Adriaan's workaround `word value not word (0)' would not work anymore. Of course there are other ways to get this value, depending on what's the real intention behind it, such as `High (Word)' (if the maximum value of a variable is meant, this is the recommended form, anyway, since it's independent of any representation issues) or just writing out the number, possibly in hex, if the actual numeric value is meant.
Yes, the "not 0" expression came from (mysql 4.1.5) C headers ......
Regards,
Adriaan van Os