## Main sections

## Data types

## Data Types

### Numbers

On "big" systems, GLBasic's default storage for numbers uses 8 bytes (64 bits). To indicate that a variable is a number you can (optionally) append a '#' to the variable name to make this clear.

These numbers are otherwise known as "double precision floating-point numbers".

On "small" systems (those with ARM processors - PocketPC, GP2X, WIZ etc), numbers are stored as 4 bytes (32 bits). These are also known as "single precision floating point numbers".

Number variables ending with a '%' are integer numbers with a 4 byte (32 bit) accuracy.

A once declared variable keeps its type, even if you leave out the character indicating the type when later referencing it.

Be aware that values typed directly into your code that are written as integers (whole numbers) may force calculations to be done as integer calculations. This may lead to unexpected results when you assign the result of a calculation to a variable that supports a decimal place but get an integer result back.

For example

MyNumber% = 1234 // Integer

Result# = MyNumber / 1000 // Result is a float value

As "Result" has been defined as a floating point number (that is, one that supports decimal places - indicated by the "#"), you would expect that "Result" would contain the value "1.234". Instead, the compiler determines that the "1000" is an integer value (as it doesn't contain a decimal point) and does an integer based calculation. The result of 1234 / 1000 as an integer calculation is "1".

To force calculations to be done as a floating point calculation, add a ".0" to the end of any number typed into your code that you wish to be interpreted as a floating point number.

If you change the above code to be

MyNumber% = 1234 // Integer

Result# = MyNumber / 1000.0 // Result is a float value

Result will end up with the expected value of "1.234"

### Strings

GLBasic stores all strings (a series of alphanumeric characters) using 1 byte (8 bits) per character. A string variable ends with a '$', which must not be left off the variable name.

You can convert strings to numbers and vice versa automatically:

a$="123.4"

b# = a$

a$ = b#

If you want to perform a mathematical operation during this conversion, you should put the term in braces to avoid adding two strings, which would just concatenate them.

a$ = 3 + 4 // "34"

a$ = (3+4) // "7"

There is no maximum size for string variables - you could keep adding text until you run out of system memory.