0

When reading a decimal value with 12 digits after decimal point from a table using resultSet.getBigDecimal("COL1") it returns the value with some additional numbers at the end. For instance, the value on the table is 29963.26, but the value returned by rs.getBigDecimal and rs.getString is 29963.260000000002

Another example, value on the table is 26.76 but the value returned by rs.getBigDecimal('COL') is 26.759999999998

Any suggestions to get over it?

Thulasi
  • 126
  • 3
  • 19
  • What is the actual datatype of the column you're retrieving? The behaviour (retrieved value) suggests it is actually a double precision. Please provide a [mre]. – Mark Rotteveel Nov 14 '19 at 11:54
  • Yes, the database we are using is HP NonStop SQL/MX and the datatype used is double precision. To simplify this how do I round the following values to 69.0235 and retain scale as 12, so the final value should be 69.023500000000, BigDecimal priceInBg = new BigDecimal("69.023499999999"); priceInBg.setScale(12, RoundingMode.HALF_DOWN) – Thulasi Nov 14 '19 at 16:51

0 Answers0