How do I convert the integer -2 to its hex 0xfe???
I tried hex() but it gives me -0x2
j3nny
0
Newbie Poster
Recommended Answers
Jump to Post0xfe is not the hex of -2, it is the hex of 256 - 2. You can use
>>> hex(-2 % 256) '0xfe' >>> hex(256 - 2) '0xfe'
All 2 Replies
Reply to this topic
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.