arnaudroger / SimpleFlatMapper

Fast and Easy mapping from database and csv to POJO. A java micro ORM, lightweight alternative to iBatis and Hibernate. Fast Csv Parser and Csv Mapper
http://simpleflatmapper.org
MIT License
440 stars 76 forks source link

NumberBigDecimalConverter uses improper BigDecimal constructor causing floating point error #771

Open basme opened 2 years ago

basme commented 2 years ago

NumberBigDecimalConverter class, when constructing a target BigDecimal instance, uses new BigDecimal(double) constructor which can cause floating point error, as described in constructor's javadoc. Use case example: when used with jooq, this implementation causes unexpected behavior: numeric non-integer value stored in DB is presented in biased incorrect BigInteger value in target entity.

As per javadoc, it is recommended to use either BigDecimal(String) constructor or BigDecimal.valueOf(double) method.