# FLOAT

A double precision (64-bit) IEEE 754 floating point. The rounding mode is round to nearest.

Literals in base 10 may begin with an optional negative sign `-`, followed by whole part, optionally followed by fractional part, optionally followed by exponent where:

• Decimal digit: Characters `0` through `9`.
• Whole part: A nonempty sequence of decimal digits.
• Fractional part: A decimal point `.` followed by a nonempty sequence of decimal digits.
• Exponent: An `e` marker followed by optional `-` / `+` sign followed by a nonempty sequence of decimal digits.

Literals in base 16 may begin with an optional negative sign `-`, followed by hexadecimal base indicator `0x`, followed by whole part, optionally followed by fractional part, optionally followed by exponent where:

• Hexadecimal digit: Decimal digit or letters `a` through `f` or letters `A` through `F`.
• Whole part: A nonempty sequence of hexadecimal digits.
• Fractional part: A decimal point `.` followed by a nonempty sequence of hexadecimal digits.
• Exponent: A `p` marker followed by optional `-` / `+` sign followed by a nonempty sequence of decimal digits. Note that the exponent is always given in base 10, even when the whole and fractional parts are in hexadecimal.

Hexadecimal floating point values are case insensitive.

Negative values are also permitted. The `-` forms part of literal syntax.

Literals missing both the fractional part and the exponent will be interpreted as `INTEGER` literals, and implicit conversion to a `FLOAT` constant will be performed at compile time provided that the integer in question can be accurately represented as a `FLOAT` quantity. A compilation error is given if this conversion cannot be performed.

For example:

``````1
2
3
4
5
6
7
8
9
declare local var.f FLOAT;
set var.f = 1.2;
set var.f = 1.2e3;
set var.f = -1.2e-3;
set var.f = 1e3;
set var.f = 0xA.B;
set var.f = 0xA.Bp3;
set var.f = -0xA.Bp-3;
set var.f = 0xAp3;
``````

Floating point values have several classifications.

Conversions to STRING values are always rendered to 3dp (3 decimal places) precision:

``````1
2
3
declare local var.f FLOAT;
set var.f = -3.5;
log var.f; /* "-3.500" */
``````