Blitz:Data types

From Amiga Coding
Revision as of 00:45, 1 August 2015 by Daedalus (talk | contribs) (Primitive Data Types)
Jump to: navigation, search

Primitive Data Types

Blitz Basic / AmiBlitz supports six standard data types that can be stored in variables by your program. Five of these are used to store numbers in various formats, and a string data type is used to store strings of characters. The various properties and limitations of each type are listed below:

Name Extension Size Minimum Maximum Notes
Byte .b 1 byte (8 bits) -128 +127 Integer only
Word .w 2 bytes (16 bits) -65536 +65535 Integer only
Long / Long Word .l 4 bytes (32 bits) -231 +231 Integer only
Quick .q 4 bytes (32 bits) -32768 +32767 Quick-Float with fixed decimal point, +/-15 bit.16 bit format (1 in 65536 precision after decimal point). Quicker than emulating the float types in software but slower than integers and slower than float types using a hardware FPU.
Float .f 4 bytes (32 bits) -9*1018 +9*1018-1 Floating point number as supported by the Amiga's standard floating point libraries, +/-23bits+/-7 bits format. Slow to emulate in software but very fast if hardware FPU is used. Slower than integers.
Double Float .d 8 bytes (64 bits) -Huge +Huge Double-precision floating point number, +/-52bits+/-10 bits format. No software emulation so requires a hardware FPU to be used. Not supported in Blitz Basic 2.1 and earlier.
String .s or $ Variable, dynamically increased as required Null (\0) String buffer size String of 8-bit characters in memory terminated automatically by a null character (\0). Size does not normally need to be declared. $ extension is included as in other BASIC dialects, and if used, must be included every time the variable is referenced.

Default Data Types

By default, any variables used in Blitz that are not explicitly defined as a particular type are created as quick types.


NewTypes are custom data types defined by your code. They contain one or more variables of any type grouped together. They are the equivalent of a Struct or Structure in C.