This isn't so much a question but more like a "what the?!".
If I have the float value "3.4173900000000001E+000" and issue a "ROUND( 3.4173900000000001E+000, 2 )", I get (drum roll) 3.4199999999999999E+000.
Cast as a dec with 2 decimal places and viola! You get 3.41739 rounded to 3.41.
This statement shows it all.
SELECT FLOAT(3.41739) AS NUM,
ROUND( FLOAT(3.41739), 2 ) AS ROUNDED_NUM,
CAST( ROUND( FLOAT(3.41739), 2 ) AS DEC(5,2) )
AS CASTED_ROUNDED_NUM
FROM SYSIBM/SYSDUMMY1
Output:
NUM ROUNDED_NUM CASTED_ROUNDED_NUM
3.4173900000000001E+000 3.4199999999999999E+000 3.41
Of course I know to cast it to 3 decimal places before the round, but still...
If I have the float value "3.4173900000000001E+000" and issue a "ROUND( 3.4173900000000001E+000, 2 )", I get (drum roll) 3.4199999999999999E+000.
Cast as a dec with 2 decimal places and viola! You get 3.41739 rounded to 3.41.
This statement shows it all.
SELECT FLOAT(3.41739) AS NUM,
ROUND( FLOAT(3.41739), 2 ) AS ROUNDED_NUM,
CAST( ROUND( FLOAT(3.41739), 2 ) AS DEC(5,2) )
AS CASTED_ROUNDED_NUM
FROM SYSIBM/SYSDUMMY1
Output:
NUM ROUNDED_NUM CASTED_ROUNDED_NUM
3.4173900000000001E+000 3.4199999999999999E+000 3.41
Of course I know to cast it to 3 decimal places before the round, but still...