March 28, 2024, 12:04:32 PM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


Unsigned Integer Question

Started by Haim, May 15, 2008, 04:41:01 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Haim

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

Ionic Wind Support Team

Use the sprint funtion or the using command with the "u" modifier. 

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

Paul.
Ionic Wind Support Team

Haim

Thanks Paul.
Can I be sure that the issue is only with the display and that the value itself is correct?

Haim

Ionic Wind Support Team

The value itself is correct of course.  NumToStr accepts a DOUBLE as it's parameter, so your UINT becomes signed during the conversion.

Paul.
Ionic Wind Support Team

Haim

Thanks for the clarification.