Page 1 of 1

Issue with IDOS->HexToLong

Posted: Sat May 26, 2018 5:04 pm
by glames
Hello,

It seems that IDOS->HexToLong doesn't work always as it should.

uint32 l_number;
IDOS->HexToLong("0x880800",&l_number);
=> l_number is: 8 914 944 OK :)

uint32 l_number;
IDOS->HexToLong("0x88080000",&l_number);
=> l_number is: -2012741632 ? :( Was waiting for 2 282 225 664
As l_number is a uint32, it should be able to store a value until 4 294 967 295, no ?

Any ideas?

Thank you.
Glames

Re: Issue with IDOS->HexToLong

Posted: Sat May 26, 2018 9:21 pm
by thomasrapp
Erm, an uint32 cannot store negative numbers. If your program prints -2012741632, then something's wrong with how you print the result.

If you want to see unsigned numbers, you should use %u and not %d.

Try:

printf ("%ld %lu\n",0x88080000,0x88080000);

and you'll see that everything is correct except your debugging.

Re: Issue with IDOS->HexToLong

Posted: Sun May 27, 2018 9:33 am
by glames
Hi Thomas,

You're right. Thank you. I was using %l :(

Have a nice day,
Glames