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
-
Does this answer your question? Hex string to signed int in Pythonpicobit– picobit2023-02-16 15:56:05 +00:00Commented Feb 16, 2023 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– acw2023-02-16 16:20:50 +00:00Commented Feb 16, 2023 at 16:20
-
No, your question as asked is about interpreting an unsigned hex string as a signed integer.picobit– picobit2023-02-16 17:51:08 +00:00Commented Feb 16, 2023 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– acw2023-02-16 17:56:52 +00:00Commented Feb 16, 2023 at 17:56
Add a comment
|