From Bohemia Interactive Community
Jump to: navigation, search

Number Type

A real number, i.e. 1, -25, 6.52, 1805.6352

Numbers are stored as single precision floating point numbers, which allow for a large range of values with limited precision (generally accurate to 6 or 7 decimal places). The number data type is also sometimes referred to as "scalar" (for example, returned by the supportInfo script command).

The largest real positive number that can be entered via script is: 3.4028235e38

The largest real negative number that can be entered via script is: -3.4028235e38

Larger numbers: In scripts it is possible to generate a representation of an infinite positive or negative number which compares even larger or smaller than the above two floating point limits;

Positive infinity 1e39 = "1.#INF"

Negative infinity -1e39 = "-1.#INF"

Indeterminate (NaN) = "-1.#IND"

The finite command can be used to verify if a number represents infinity or NaN.

Technical Specification

A number is a sequence of characters starting either with a digit, an $ or a .. If it starts with a digit it may be an integer (e.g. 3), a floating point number (e.g. 3.2) or a hexadecimal number (see below). If it starts with a $ it is also a hexadecimal number and if it starts with a . it is a floating point number smaller than 0 (e.g. .1 = 0.1). If the number is not hexadecimal it may contain exactly one period and ends before the first non-digit character (except that one period of course). The only exception from that is the scientific notation.

The scientific notation in SQF has the syntax ([0-9]+.)?[0-9]+[eE][+-]?[0-9]+

That means it consists of a pre-factor that can be any number (integer or floating point). Then a e or E followed by an optional sign (+ or -) and at the end an integer (a whole number). This will then be interpreted in the following way

aEb = a * 10^b Examples: 1e2 = 1E2 = 100
5e-2 = 5E-2 = 0.05
1.234e4 = 1.234E4 = 12340

If omitted the exponent b will be considered to be zero and therefore

aE = a

Although the result is being calculated the engine will issue an error on that becasue the exponent is not optional! If the pre-factor a is omitted it is no longer a number as it doesn't start with a digit or a period. If one tries to use a hexadecimal number as the pre-factor the e will simply be interpreted as part of that hexadecimal number and therefore it is no longer a scientific notation.

Essentially numbers in SQF are in the format the atof function in C(++) expects numbers to be (See with the exception that hexadecimals can also start with a $ as well.

Hex numbers

Arma supports hexadecimal numbers in both scripts and configs. Most common notation for hex numbers is 0x followed by the hexadecimal value. Alternatively symbol $ can be used for the same thing. It is also possible to mix and match notations:

hint str 0xFF; //255 hint str $FF; //255 hint str (0xFF + $FF + 255); //765 Hexadecimal numbers are case-insensitive:

0xFF = 0xff


Degrees are a poetic label used to indicate a number returned from functions like acos and asin

It's special properties are that it will always supply a value from 0 to 360


Another poetic label for a Number. Used in angular math computations with commands like rad and deg

Scripting vs Addons

Integers and Floats

Note that unlike config.cpp's (addons), a Number in scripting language is ANY numeric entity. Floats, or integers. It is NOT the same as a config's Integer or Float. Number covers both types.


Note also, unlike config.cpp's, Boolean is a real type in scripting language. In addons, it is a poetic licence for a zero/non zero Integer. In Arma 3 command parseNumber has been extended to accept booleans:

hint str parseNumber true; //1