I'm aware I could just do 0x0 - 9223372036854775807 - 1
, but is there a bit shift operation I could do instead to make this faster? Context: I'm fed a uint64 number in hex string form but I want to store this number inside an 8 byte signed integer attr in PostgreSQL. Also, I would need a way to convert it back from signed integer to unsigned hex
Asked
Active
Viewed 53 times
0

acw
- 807
- 3
- 15
-
Does this answer your question? [Hex string to signed int in Python](https://stackoverflow.com/questions/6727875/hex-string-to-signed-int-in-python) – picobit Feb 16 '23 at 15:56
-
No, that performs a two's complement. This question is asking how to interpret an unsigned integer as a signed integer via the difference (i.e. the 9223372036854775807) – acw Feb 16 '23 at 16:20
-
No, your question *as asked* is about interpreting an unsigned hex string as a signed integer. – picobit Feb 16 '23 at 17:51
-
I see, feel free to edit the question title, but hopefully the description makes sense. Still, are there any other options? I can also repost the question title. – acw Feb 16 '23 at 17:56