I run this sql statement on Oracle 11g database
select round(79/3 + 87/3 + 86/6 + 95/6) from dual
and it returns 85
select round(79/3 + 87/3 + 86/6 + 95/6,1) from dual
returns 85.5
select round(85.5) from dual
returns a correct value 86
Does anyone know why the first SQL statement doesn't return a correct value 86
but it rounds it down to 85
??
If you do:
select 79/3 + 87/3 + 86/6 + 95/6 from dual;
Oracle will return 85.49999999999999999999999999999999999999
, which when rounded to 0 decimal places is indeed 85. It's an artifact of floating point arithmetic.