Re: Signed Hex Values
- Posted by petelomax Sep 23, 2013
- 1552 views
A proposed change ...
Signed Hex Values
Why is this a good idea? What's the advantage, etc ...
Things like E_INVALIDARG (and many many friends). I get a negative HRESULT, I know E_INVALIDARG is 0x80070057, but erm, -2147024809? What else might you suggest?
If adopted, following the same logic, we'd also have to allow the following combinations ...
+#-FFFFFFFF -- -1 -#-FFFFFFFF -- +4294967295 +#+FFFFFFFF -- +4294967295 -#+FFFFFFFF -- -1
Yes, I had spotted that potential for code obfuscation The correct values would be:
+#-FFFFFFFF -- -1 -#-FFFFFFFF -- +1 +#+FFFFFFFF -- +4294967295 -#+FFFFFFFF -- -4294967295
which just goes to show it would be quite good for that. I don't really see what the problem with any of that would be though.
The #- directive triggers a compilation error if the following hexadecimal constant is not 2, 4, or 8 characters, or 16 in 64-bit code.
Why have this restriction?
I did't think it would be sensible for the compiler to effectively decide on a quite arbitrary basis that say bit 23 was the sign bit?
And what about binary literals and hex values inside strings?
I'm not seeing the same kind of comparison requirement there, so no.