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:

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 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" */
Back to Top