Issue with IDOS->HexToLong

A forum for general AmigaOS 4.x support questions that are not platform-specific
Post Reply
glames
Posts: 21
Joined: Wed Aug 31, 2011 12:08 am

Issue with IDOS->HexToLong

Post 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
User avatar
thomasrapp
Posts: 310
Joined: Sat Jun 18, 2011 11:22 pm

Re: Issue with IDOS->HexToLong

Post 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.
glames
Posts: 21
Joined: Wed Aug 31, 2011 12:08 am

Re: Issue with IDOS->HexToLong

Post by glames »

Hi Thomas,

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

Have a nice day,
Glames
Post Reply