- Dec 12, 2022
- 357
- 2
Hi,
I'm writing a memory analyzer for Keil uVision to display memory usage instead of having to wade through map files.
I wish to convert a string of the form: 0xhhhhhhhh to a long integer so I can do calc's. I also wish to convert the result back to hex strings.
Of course I strip off the 0x and make the remaining 8 char's upper case.
The problem I have is I don't get the answer I expect: viz
Input 0x0807dc74 = 134,732,916 decimal
But the output I get is 8,597,713,124 decimal = 0x2 0076 B0E4 in Hex
I have fiddled with the Endianess and tried bytes and strings, but with no success.
I feel it's got something to do with two's complement, but I am not sure what. It is making my brain hurt.
Can someone help me.
The code in question is:
Convert hex string to long integer:
I'm writing a memory analyzer for Keil uVision to display memory usage instead of having to wade through map files.
I wish to convert a string of the form: 0xhhhhhhhh to a long integer so I can do calc's. I also wish to convert the result back to hex strings.
Of course I strip off the 0x and make the remaining 8 char's upper case.
The problem I have is I don't get the answer I expect: viz
Input 0x0807dc74 = 134,732,916 decimal
But the output I get is 8,597,713,124 decimal = 0x2 0076 B0E4 in Hex
I have fiddled with the Endianess and tried bytes and strings, but with no success.
I feel it's got something to do with two's complement, but I am not sure what. It is making my brain hurt.
Can someone help me.
The code in question is:
Convert hex string to long integer:
کد:
محتوای بلوک کدها در دسترس شما نیست. برای مشاهده بلوک کدها، وارد انجمن شوید یاثبت نام کنید
برای دیدن لینک ها باید ثبت نام کنید
برای دیدن لینک ها باید ثبت نام کنید