How to define the max number for an uint

Discussion about recent product features & solutions!
5 posts • Page 1 of 1
fmulder
Posts:330
Joined: Wed Feb 03, 2010 9:46 am

How to define the max number for an uint

Post by fmulder »

I got a weird question from a colleague and I was unable to answer.

The following script code will correctly output the numerical value 2147483648

Code: Select all

  uint uMask = 1

Gertjan van Schijndel
Posts:634
Joined: Mon Aug 02, 2010 10:37 am

Re: How to define the max number for an uint

Post by Gertjan van Schijndel »

When no type suffix is used the control interpreter uses the data type integer.
So to define a constant outside the integer range you need to use a suffix, these suffixes can be found in the online help -> CONTROL -> Introduction to CONTROL -> Data types
  • uint/unsigned: u or U
  • long: l or L
  • ulong: ul or UL
By the way for defining the max/min number you can use one of the max/min functions, like 'maxUINT()' (which returns 4294967295)

fmulder
Posts:330
Joined: Wed Feb 03, 2010 9:46 am

Re: How to define the max number for an uint

Post by fmulder »

Just to clarify. This is the correct way to define the largest possible unsigned integer:

Code: Select all

  uint uMasker = 2147483648u;
  DebugN( uMasker );

Gertjan van Schijndel
Posts:634
Joined: Mon Aug 02, 2010 10:37 am

Re: How to define the max number for an uint

Post by Gertjan van Schijndel »

Yes, that is the correct way to define an unsigned with the value 2147483648.

The correct way to define the largest possible unsigned integer:

Code: Select all

uint uMasker = maxUINT();   // or
uint uMasker = 0xFFFFFFFFu; // or
uint uMasker = 4294967295u;

fmulder
Posts:330
Joined: Wed Feb 03, 2010 9:46 am

Re: How to define the max number for an uint

Post by fmulder »

Yes, you are right.
I guess it is time to go home. This was a stupid mistake

Thanks

:( :(
Share the fun
Frenk

5 posts • Page 1 of 1