What is the UInt32 data type in Visual Basic .NET?

What is the UInt32 datatype in VB.NET?

Can someone inform me about its bit length and the differences between UInt32 and Int32? Is it an integer or floating point number?

13.10.2009 16:59:19

It's a 32 Bit unsigned integer.

13.10.2009 17:02:10

It's an unsigned 32 bit integer:

  • U for unsigned
  • Int for integer
  • 32 for 32

Or you could just look at the documentation:

Represents a 32-bit unsigned integer.

13.10.2009 17:02:10

Data types in VB.NET notes the following:

UInt32 - 32 bit unsigned integer

Thus, it is 32 bits long, an integer.

13.10.2009 17:02:28

A UInt32 is an unsigned integer of 32 bits. A 32 bit integer is capable of holding values from -2,147,483,648 to 2,147,483,647.

However, as you have specified an unsigned integer it will only be capable of storing positive values. The range on an unsigned 32 bit integer is from 0 to 4,294,967,295.

Attempts to assign values to an Int or UInt outside of its range will result in an System.OverflowException.

Obviously, both UInt32 and Int32 are integers (not floating point), meaning no decimal portion is permitted or stored.

It may also be interesting to note that Integer and System.Int32 are the same in .NET.

For performance reasons you should always try to use Int32 for 32 bit processors and Int64 for 64 bit processors as loading these types to and from memory will be faster than other options.

Finally, try to avoid use of unsigned integers as they are not CLS compliant. If you need positive only integer that has the upper limit of the UInt32 it is better to use an Int64 instead. Unsigned integers are usually only used for API calls and the like.

13.10.2009 21:14:52