Re: Signed Hex Values

new topic     » goto parent     » topic index » view thread      » older message » newer message
DerekParnell said...
petelomax said...

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?

DerekParnell said...

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 obfuscationblink 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.

petelomax said...

The #- directive triggers a compilation error if the following hexadecimal constant is not 2, 4, or 8 characters, or 16 in 64-bit code.

DerekParnell said...

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?

DerekParnell said...

And what about binary literals and hex values inside strings?

I'm not seeing the same kind of comparison requirement there, so no.

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu