Printing hexadecimals #10728
Answered
by
dlech
cve2022
asked this question in
Using MicroPython
Printing hexadecimals
#10728
Replies: 2 comments 5 replies
-
hex(mem32[0xE000E400] & 0xffffffff) |
Beta Was this translation helpful? Give feedback.
3 replies
Answer selected by
jimmo
-
Follow-up question, it will always work? Why? I tested with Python and it works too, FWIW. I have read here and there (on topics about similar questions) that Python does not have the concept of unsigned int, but this result contradicts that statement. In C, AFAIR, if one has e.g., an int32_t and a uint32_t in the same expression, the int32_t is promoted automatically. Ofc the right way is casting the operands to make sure the result is what one intended. This expression suggests Python behaves the same way. Or am I missing something? |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
When I use hex() or hexadecimal format with print with the value returned by mem32, if the most significant bit is 1, then I get a signed string.
The only way I could find to print the value as an unsigned int hex was using an array:
Is there a simpler way?
Beta Was this translation helpful? Give feedback.
All reactions