IonicWind Software

Aurora Compiler => Coding Help - Aurora 101 => Topic started by: Haim on May 15, 2008, 04:41:01 AM

Title: Unsigned Integer Question
Post by: Haim on May 15, 2008, 04:41:01 AM
Hello,
This is what I did:

UINT n= 1<<31
string s=numtostr(n);

when I display the string I see -2147483648
Why is the sign negative the result should be positive and the variable type is UINT
Can someone explain this please

Thanks,

Haim
Title: Re: Unsigned Integer Question
Post by: Ionic Wind Support Team on May 15, 2008, 01:42:02 PM
Use the sprint funtion or the using command with the "u" modifier. 

print( using("%u#",n) );

Paul.
Title: Re: Unsigned Integer Question
Post by: Haim on May 15, 2008, 09:07:34 PM
Thanks Paul.
Can I be sure that the issue is only with the display and that the value itself is correct?

Haim
Title: Re: Unsigned Integer Question
Post by: Ionic Wind Support Team on May 16, 2008, 08:12:57 AM
The value itself is correct of course.  NumToStr accepts a DOUBLE as it's parameter, so your UINT becomes signed during the conversion.

Paul.
Title: Re: Unsigned Integer Question
Post by: Haim on May 17, 2008, 10:51:02 PM
Thanks for the clarification.