Issue with IDOS->HexToLong

A forum for general AmigaOS 4.x support questions that are not platform-specific

Issue with IDOS->HexToLong

Postby glames » Sat May 26, 2018 6:04 pm

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
glames
 
Posts: 16
Joined: Wed Aug 31, 2011 1:08 am

Re: Issue with IDOS->HexToLong

Postby thomasrapp » Sat May 26, 2018 10:21 pm

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.
User avatar
thomasrapp
 
Posts: 256
Joined: Sun Jun 19, 2011 12:22 am

Re: Issue with IDOS->HexToLong

Postby glames » Sun May 27, 2018 10:33 am

Hi Thomas,

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

Have a nice day,
Glames
glames
 
Posts: 16
Joined: Wed Aug 31, 2011 1:08 am


Return to General AmigaOS

Who is online

Users browsing this forum: No registered users and 7 guests

cron