Integer datatypes

From Xojo Documentation

Data Type


There are several intrinsic integer datatypes which differ by:

  • Their ability to hold negative and positive values (signed integers), or positive only (unsigned integers). The name of unsigned integer types usually begins with the letter "U"
  • The range of values they can hold, which is directly related to the number of bytes used for their storage (in memory or on disk). The storage size is traditionally expressed in bits instead of bytes (1 byte = 8 bits): 8-, 16-, 32- and 64-bits.
  • The Integer type is an alias to the platform's native signed integer type. On 32-bit builds, this ends up being Int32 and on 64-bit builds this ends up being Int64.

The default value for every integer type is 0.

The following table summarizes these data types.

Integer Data Type Summary
Data Type Number of Bytes Range
Int8 1 -128 to 127
Int16 or Short 2 -32,768 to 32,767
Int32 4 -2,147,483,648 to 2,147,483,647
Int64 8 -2^63 to 2^63-1
-9,223,372,036,854,775,808 to +9,223,372,036,854,775,807
UInt8 or Byte 1 0 to 255
UInt16 2 0 to 65,535
UInt32 4 0 to 4,294,967,295
UInt64 8 0 to 2^64-1 (18,446,744,073,709,551,615)

Notes

If you assign a value that is larger than what the integer type can hold, then the value will "overflow". This usually means the value will wrap around. This applies to all the data types.

Example

The following declares an Int64.

This example demonstrates overflow. If you assign a number larger than 2,147,483,647 to an Int32, it will wrap around to negative values.

Var i As Int32
i = 2147483647 + 1000
// i is now -2147482649
Break

See Also

Int16, Int32, Int64, Int8, Integer, UInt16, UInt32, UInt64, UInt8 data types