Rounding issue in SQL output

DazzaL

Member
when you display a number that is defined with over 17 digits of precision, plsql developer will show a rounding error on the number displayed.

eg see
select cast(-.005643 as number(30,18)) from dual
plsql developer will show -0.00564299999999999

vs
select cast(-.005643 as number(30,17)) from dual
plsql developer will show -0.00564300000000000

sqlplus will show the correct output each time

> set numwidth 30
> select cast(-.005643 as number(30,17)) from dual;

CAST(-.005643ASNUMBER(30,17))
------------------------------
-.005643

1 row selected.

> select cast(-.005643 as number(30,18)) from dual;

CAST(-.005643ASNUMBER(30,18))
------------------------------
-.005643

1 row selected.

version:
PL/SQL Developer
Version 15.0.2.2054 (64 bit)
01.135493 - Unlimited user license
Service Contract: 2023-02-01
Style: Sky Blue
Windows 10 Build 19044
en-GB(2057)/English (United Kingdom)

error.png
 
This is a floating point rounding issue. If you go to Configure > Preferences > SQL Window you can enable the "Number fields to_char" option to display the number values with full Oracle precision in the SQL Window.
 
Back
Top