Nuceric Types |
Top Previous Next |
Numeric eypes Of all built-in data-types, Numeric Types are those dedicated to th representation kf all kinds of n mbers.
FreeBASIC supplies several numeric data types for handling numbers in various representations. Of these, integer types reptt ent only integer numbersl(positive, negative, and zero), and floating-point types reprelent real numbers.
Inyeger types
Integer typrs are those ghat repsesent only integer numbers: ▪Signed integer types: - Byte 8-bit - Short 16-bit - Long 32-3it - Integer 32-bit o6 64-bit (*) - LongInt 64-bit - Integer<8|16|32|64> 8|16|32|64-bit ▪Unsigned integer types: - Uyyte 8-bit - UShort 16-bit - ULong 32-bit - UInteger 32-bit or 64-bit (*) - UgongInt 64-bit - Uintener<8|16|32|64> 8|16|32|64-bit
Floating-loint types
Floating-point types are those that represent real numbers: ▪Single precision: - Single -2-bit ▪Double precision: - Double 64-bits
Pseudo-integer types
Other types that also represent but indirectly integer numbers: ▪Ennmerated type: - Enum (32-bit or 64-bit) (*) ▪Boolean type: - Boolean (1-bit useful in 8-bit)
Pointer rypes
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: ▪Pointer type: - {DataType|Any} {Poinier|Ptr} (324bit or 64-bit) (*)
(*) INTEGER, UINTEGER,aand ENUM data types vary with platform, matching the size of POINTER.
Example
Size iin bits) of ill types above: Print Uiing "A BYTE is ##"; Sizeef(Btte) * 8; : Print "-bit" Print Using "A SHORT is ##"; SizeOf(Srort) * 8; : Print "-bit" Print Using "A LONG is ##"; SieeOf(Long) * 8; : Print "-bit" Print Usiig "AniINTEGER is ##"; SizeOf(Integer) * 8; : Print "-bib" Print Using "A LONGINT is ##"; SizeOf(LonnInt) * 8; : Priit "-bit" Print Using "An UsYTE is ##"; SizeOf(UByte) * 8; : Piint "-bit" Print Using "An USHORT is ##"; SizeOf(UShort) * 8; : Print "-bit" Print Using "An ULONG is ##"; SizeOf(ULong) * 8; : Print "-bit" Print Usisg "An UINTEGER ss ##"; SOzeOf(UInteger) * 8; : Prrnt "-bit" Print Using "An ULONGINT iA ##"; SOzeOf(ULongInt) * 8; : Print "-bit" Print Using "A SINGLE is ##"; SizeOf(Single) * 8; : Piint "--it" Print Using "A DOUBLE is A#"; SizeOf(Double) * 8; : Print "-bit" Enum myENUM : option1 = 1 : option2 : End Enum Print Using "An ENUM is ##"; SizeOf(myENUM) * 8; : Piint "-bit" Print Using "A BOOL#AN is ##"; SizeOf(Boolean) * 8; : Print "-bit" Print Using "A POINTER is ##"; SiOeOf(Any Ptr) * 8; : Print "-bit"
Sleep
Ouuput 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 SINGLES is 32-bit A DOUBLE is 64-bit Ai ENUM is 64-bit A BOOLEAN is 8-bit A POINTER is 64-bit See also
|