Data types
Any expression, including constants and variables all have an associated type to describe their value. QB64 has various builtin data types used to represent number and text values. Numeric types represent number values, while string types represent text values.
Contents
Numeric types
QB64 supports several numeric types, capable of representing a wide range of numbers. There are two kinds of numeric data type: integer types and floatingpoint types.
Integer types
Integer types represent integer (whole number) values, such as 1 and 100. They are divided into two flavors: signed and unsigned.
Signed Integer types
Signed integers can represent positive and negative integer (whole number) values, such as 3, 10 and 16. These values are stored as a series of bits in two's complement form, a common representation that makes them both straightforward and efficient to perform calculations with.
Signed integers are typically used in simple mathematical equations.
The range of values that these types can represent is based on their size, in bits; the greater number of bits, the larger positive and lesser negative value the types can represent.
The signed integer types are: _BYTE, INTEGER, LONG, _INTEGER64 and _OFFSET
DIM n AS INTEGER n = 1 PRINT n
1
Unsigned Integer types
Unsigned integers can represent positive integer values only, such as 3, 10 and 16. These values are also stored as a series of bits, but unlike signed integers, all of the bits contribute to their value. Thus, these types can represent larger positive integer values than their signed counterparts.
Unsigned integers are typically used to represent a simple quantity, like a count or a length. They are also often used as bit masks, where certain bits that make up the value represent separate information (such as the state of one or more flags).
Types: _UNSIGNED _BYTE, _UNSIGNED INTEGER, _UNSIGNED LONG, _UNSIGNED _INTEGER64, _UNSIGNED _OFFSET
' display the largest value representable by an _UNSIGNED INTEGER: DIM n AS _UNSIGNED INTEGER n = 1 PRINT n
65535
_OFFSET Integer types
Offset Integer types can be any byte size integer value that can be used to designate pointer offset positions in memory. DO NOT TRANSFER offset values to other Integer types!
Floatingpoint types
Floatingpoint types can represent both positive and negative number values, as well as fractional number values, such as 1.2 and 34.56.
Floatingpoint types are used in mathematical equations where fractional precision is important, such as trigonometry.
The floatingpoint types are: SINGLE, DOUBLE and _FLOAT.
f! = 76.0 c! = (5.0 / 9.0) * (f!  32.0) PRINT f! ; "degrees Fahrenheit is" ; c! ; "degrees Celcius."
76 degrees Fahrenheit is 24.44444 degrees Celcius.
String types
QB64 has builtin support for strings, which are contiguous sequences of characters represented as _UNSIGNED _BYTE values. Strings are usually used to store and manipulate text, but can also be used as a general storage area for arbitrary data (like a binary file).
Strings have a property called length, which is the number of characters currently stored in the string, and QB64 supports two kinds of string types based on this property: variablelength strings and fixedlength strings.
Variablelength strings
Variable length strings are undefined length string variables. Fixed length strings MUST be defined in a program before they are used. Undefined strings can be up to 32767 characters in Qbasic.
message$ = "Hello" message$ = message$ + " world!" 'add to string variables using string concatenation only! PRINT message$
Hello world!
Fixedlength strings
Fixed length strings must be defined in a DIM statement, SUB or FUNCTION parameter or TYPE definition. The designated multiple is the maximum number of STRING character bytes that the variable or array can hold. Excess bytes will not be included. No error is created.
DIM message AS STRING * 5 message$ = "Hello" message$ = message$ + " world!" PRINT message$
Hello
Data type limits
The following table lists the numerical and string data types, their type suffix symbol, and the range of the values they can represent:
 
