Data Types - Integer


Positive and Negative Numbers / Integers

sbyte (-128 to 127)Integer from -2^7 to 2^7-1, System.SByte
1 byte (8 bits)
short (-32,768 to 32,767)Integer from -2^15 to 2^15-1 System.Int16
2 bytes (16 bits)
Integer in VBA
int (-2,147,483,648 to 2,147,483,647)Integer from -2^31 to 2^31-1, System.Int32
4 bytes (32 bits)
long (-9.2 E 18 to 9.2 E 18)Integer from -2^63 to 2^63-1 System.Int64
8 bytes (64 bits)
Abbreviation Suffix - l or L
sbyte (-128 to 127)
Integer from -2^7 to 2^7-1, System.SByte
1 byte (8 bits)
short (-32,768 to 32,767)
Integer from -2^15 to 2^15-1 System.Int16
2 bytes (16 bits)
Integer in VBA
int (-2,147,483,648 to 2,147,483,647)
Integer from -2^31 to 2^31-1, System.Int32
4 bytes (32 bits)
long (-9.2 E 18 to 9.2 E 18)
Integer from -2^63 to 2^63-1 System.Int64
8 bytes (64 bits)
Abbreviation Suffix - l or L

Positive Numbers Only / Integers
These are also known as unsigned integers.

byte (0 to 255)Positive Integers up to 2^8-1, System.Byte
1 byte (8 bits)
ushort (0 to 65,535)Positive Integers up to 2^16-1, System.UInt16
2 bytes (16 bits)
uint (0 to 4,294,967,295)Positive Integers up to 2^32-1, System.UInt32
4 bytes (32 bits)
Abbreviation Suffix - u or U
ulong (0 to 1.84 E 19)Positive Integers up to 2^64-1, System.UInt64
8 bytes (64 bits)
Abbreviation Suffix - ul or UL
byte (0 to 255)
Positive Integers up to 2^8-1, System.Byte
1 byte (8 bits)
ushort (0 to 65,535)
Positive Integers up to 2^16-1, System.UInt16
2 bytes (16 bits)
uint (0 to 4,294,967,295)
Positive Integers up to 2^32-1, System.UInt32
4 bytes (32 bits)
Abbreviation Suffix - u or U
ulong (0 to 1.84 E 19)
Positive Integers up to 2^64-1, System.UInt64
8 bytes (64 bits)
Abbreviation Suffix - ul or UL

The default value type for any literal is "int"


No Overflow

Integers use modulo arithmetic, so no overflow can occur

int myFirstInteger = 2147483647; 
int mySecondInteger = 10
int myTotal = myFirstInteger + mySecondInteger;
System.Diagnostics.Debug.Print myTotal; '-2147483648;


Division follows standard "integer division" rules when using integer types


Division by Zero

Division by zero causes an exception for integer types (DivideByZeroException)



© 2024 Better Solutions Limited. All Rights Reserved. © 2024 Better Solutions Limited TopPrevNext