In Liberty BASIC, numeric variables hold either a double-precision floating point value, or an integer. A floating point value will be converted to an integer if its fractional part is zero when it is assigned to a variable. Integers in Liberty BASIC can be huge.

Only nine digits are displayed when floating point values are printed, unless the USING() function is used to force the display of the number of digits desired after the decimal point.

When first referenced, numeric variables equal 0. Values are assigned to variables with the equals sign "=".

myVar = 42

In the following code, the variable "totalNum" is 0 to begin, so adding 3 to it gives it a value of 3. Adding 8 to it in the next line gives it a value of 11.

totalNum = totalNum + 3

'totalNum now contains the value 3

totalNum = totalNum + 8

'totalNum now contains the value 11

NOTE: Liberty BASIC does not support the CONST keyword that is common in some other forms of BASIC such as QBASIC.

Negative numbers.

Liberty BASIC does not support changing the sign of a variable directly by preceding it with a negative sign "-". Instead the variable must be multiplied by -1

'WILL NOT WORK!

num1 = 7

num2 = -num1

print num2

'USE THIS METHOD

num1 = 7

num2 = -1 * num1

print num2

GLOBAL

In general, variables used in the main program code are not visible inside functions and subroutines. Variables inside functions and subroutines are not visible in the main program. Liberty BASIC 4 introduces the GLOBAL statement to create global variables. Variables declared as GLOBAL can be seen everywhere in a program. See GLOBAL. The special system variables like WindowWidth, WindowHeight, etc. now have true global status. GLOBALS are specified and used like this: