0

I am facing very strange issue when retrieving data from result set. Below code should return 3.67 as it's the value persist in Database. But below code is returning 3.67000008 every time. When I tried to get this value from my Junit it's working fine.

double value = resultSet.getDouble(i);

But during opening the screen it's returning 3.67000008. I cross verified that both code is using same oracle driver (ojdbc7-12.1.0.2b). I used below approaches also but result are same:

BigDecimal value = resultSet.getBigDecimal(i);
  • 1
    3.67 cannot be represented exactly in floating-point. – user207421 Nov 27 '17 at 22:28
  • 1
    Possible duplicate of [Is floating point math broken?](https://stackoverflow.com/questions/588004/is-floating-point-math-broken) – Joe C Nov 27 '17 at 22:28
  • 1
    What is the data type in the database? –  Nov 27 '17 at 22:35
  • 1
    This Question is incomplete. Please post a [MCVE](https://stackoverflow.com/help/mcve) with all necessary SQL to create a simple little table showing your issue. – Basil Bourque Nov 27 '17 at 23:14
  • FWIW, 3.67 stored as float is exactly `3.6700000762939453125`, as double is exactly `3.6699999999999999289457264239899814128875732421875`. So it seems to be stored as float (binary32 IEEE-754). . – Rudy Velthuis Nov 28 '17 at 13:29

0 Answers0