Numeric Types

Of all built-in data-types, Numeric Types are those dedicated to the representation of all kinds of numbers.

FreeBASIC supplies several numeric data types for handling numbers in various representations.
Of these, integer types represent only integer numbers (positive, negative, and zero), and floating-point types represent real numbers.

Integer types
Integer types are those that represent only integer numbers:

Floating-point types
Floating-point types are those that represent real numbers:
  • Single precision:
  • - SINGLE 32-bit
  • Double precision:
  • - DOUBLE 64-bits

Pseudo-integer types
Other types that also represent but indirectly integer numbers:
  • Enumerated type:
  • - ENUM (32-bit or 64-bit) (*)
  • Boolean type:
  • - BOOLEAN (1-bit useful in 8-bit)

Pointer types
Pointers are types whose values (uinteger) are addresses in memory (they are said to 'point' to this memory).
The type of data that is pointed to depends on the type of pointer (an Integer Pointer points to Integer data).
Pointers are declared like any other variable, with the suffix pointer or ptr following the type name:

(*) INTEGER, UINTEGER, and ENUM data types vary with platform, matching the size of POINTER.

Size (in bits) of all types above:
Print Using "A  BYTE     is ##"; SizeOf(Byte)     * 8; : Print "-bit"
Print Using "A  SHORT    is ##"; SizeOf(Short)    * 8; : Print "-bit"
Print Using "A  LONG     is ##"; SizeOf(Long)     * 8; : Print "-bit"
Print Using "An INTEGER  is ##"; SizeOf(Integer)  * 8; : Print "-bit"
Print Using "A  LONGINT  is ##"; SizeOf(LongInt)  * 8; : Print "-bit"
Print Using "An UBYTE    is ##"; SizeOf(UByte)    * 8; : Print "-bit"
Print Using "An USHORT   is ##"; SizeOf(UShort)   * 8; : Print "-bit"
Print Using "An ULONG    is ##"; SizeOf(ULONG)    * 8; : Print "-bit"
Print Using "An UINTEGER is ##"; SizeOf(UInteger) * 8; : Print "-bit"
Print Using "An ULONGINT is ##"; SizeOf(ULongInt) * 8; : Print "-bit"
Print Using "A  SINGLE   is ##"; SizeOf(Single)   * 8; : Print "-bit"
Print Using "A  DOUBLE   is ##"; SizeOf(Double)   * 8; : Print "-bit"
Enum myENUM : option1 = 1 : option2 : End Enum
Print Using "An ENUM     is ##"; SizeOf(myENUM)   * 8; : Print "-bit"
Print Using "A  BOOLEAN  is ##"; SizeOf(BOOLEAN)  * 8; : Print "-bit"
Print Using "A  POINTER  is ##"; SizeOf(Any Ptr)  * 8; : Print "-bit"

Output example for win64:
A  BYTE     is  8-bit
A  SHORT    is 16-bit
A  LONG     is 32-bit
An INTEGER  is 64-bit
A  LONGINT  is 64-bit
An UBYTE    is  8-bit
An USHORT   is 16-bit
An ULONG    is 32-bit
An UINTEGER is 64-bit
An ULONGINT is 64-bit

A  SINGLE   is 32-bit
A  DOUBLE   is 64-bit

An ENUM     is 64-bit

A  BOOLEAN  is  8-bit

A  POINTER  is 64-bit

See also
Back to Programmer's Guide
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki phatcode