Discussion about recent product features & solutions!
fmulder
Posts: 330 Joined: Wed Feb 03, 2010 9:46 am
How to define the max number for an uint
Post
by fmulder » Thu Dec 01, 2016 9:33 am
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
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 » Thu Dec 01, 2016 9:48 am
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 » Thu Dec 01, 2016 12:18 pm
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 » Thu Dec 01, 2016 3:10 pm
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 » Thu Dec 01, 2016 3:16 pm
Yes, you are right.
I guess it is time to go home. This was a stupid mistake
Thanks
Share the fun
Frenk