Floating point to string conversion
The default formatting of a DECIMAL(P)
, SMALLFLOAT
and
FLOAT
adapts to the significant digits of the value.
Floating point decimal types (like DECIMAL(5)
) can store a large range of
values, with a variable number of digits after the decimal point: For example, a
DECIMAL(5)
can store 12345 as well as 0.12345. See DECIMAL(p,s) for more details about floating point decimal
types.
With Genero 2.50, the conversion to string from a DECIMAL(P)
,
FLOAT
and SMALLFLOAT
has been revised, to keep all
significant digits and avoid data loss.
DECIMAL(12)
:MAIN
DEFINE str STRING, dec12, dec12_bis DECIMAL(12)
LET dec12 = 10.12999
LET str = dec12
DISPLAY str
LET dec12_bis = str
DISPLAY (dec12 == dec12_bis)
END MAIN
10.13
0
10.12999
1
Values Vers<2.50 Vers>=2.50
-------------------------------------------------
1.23456e123 1.23456e123 1.23456e123
1.23456e40 1.235e40 1.23456e40
123.456 123.46 123.456
123456.0 123456.0 123456.0
0.123456 0.12 0.123456
0.0123456 0.01 0.0123456
0.00123456 0.00 0.00123456
1.23456e-08 0.00 1.23456e-08
DECIMAL(P)
to string conversion rounds to 2 digits,
define the following FGLPROFILE entry (this applies to all
contexts):fglrun.decToCharScale2 = true
DECIMAL(P)
only in the context of the PRINT
statement
in reports. (the fglrun.decToCharScale2
and
fglrun.decToCharScale2.print
configuration parameters are
exclusive):fglrun.decToCharScale2.print = true
Do not use the fglrun.decToCharScale2*
configuration parameters, unless
you have migration issues. These configuration parameters apply only to DECIMAL(P)
types: FLOAT
and SMALLFLOAT
conversions to string is not impacted.