Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Convert a negative value into hexadecimal
Message
From
17/01/2003 12:00:30
 
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Miscellaneous
Thread ID:
00742608
Message ID:
00742932
Views:
20
>This way it works, however the result is different. I will try if it isn't rejected by the WinAPI function.

That's the way it is. It's nothing to do with the API function. The result is different because you take it forward.

Take your sample number:
-2141040952 = "80 62 4E C8"
It will stored in memory/register as "C8 4E 62 80"
You will get the wrong result if you take it forward. So you must take it backward.
cHex = ""
cHex = cHex + Right(Transform(Asc(SubStr(cRes, 4, 1)), "@0"), 2)
cHex = cHex + Right(Transform(Asc(SubStr(cRes, 3, 1)), "@0"), 2)
cHex = cHex + Right(Transform(Asc(SubStr(cRes, 2, 1)), "@0"), 2)
cHex = cHex + Right(Transform(Asc(SubStr(cRes, 1, 1)), "@0"), 2)

And it is the way CPU stored DWORD in memory/register.
Btw, just a curiousity. Why don't you use Transform(-2141040952, '@0'), the result is correct.

>Thanks a lot for you help.
Anytime :)
Herman
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform