Signed Hex Values
- Posted by petelomax Sep 22, 2013
- 1633 views
A proposed change, in documentation form.
Signed Hex Values
By default hexadecimal values are unsigned. Use "#-" to define signed hexadecimal values, eg:
#FFFFFFFF -- +4294967295 #-FFFFFFFF -- -1 #80070057 -- +2147942487 #+80070057 -- +2147942487 #-80070057 -- -2147024809 -- (the desired value for E_INVALIDARG) -#80070057 -- -2147942487
Note that "#-" is a compiler directive, rather than a unary minus as just seen in that last example. You can also code "#+" for alignmnent purposes, which behaves identically to "#". Some more examples:
#00000001 -- +1 #+00000001 -- also +1 #-00000001 -- also +1 (!! make sure you understand why this is plus 1 !!) -#00000001 -- -1 #-FF -- -1 #-00FF -- +255 (make sure you properly sign-extend short forms when editing them) if offset>=#-80 and offset<=#7F then use_short_form() end if if offset>=-128 and offset<=127 then use_short_form() end if -- (same as above)
The #- directive triggers a compilation error if the following hexadecimal constant is not 2, 4, or 8 characters, or 16 in 64-bit code.
Comments welcome.
Pete