HP Nonstop Tandem T4SQLMX driver double precision issue

余生长醉 提交于 2021-01-29 13:30:20

问题


I use T4SQLMX type 4 jdbc driver to read a double precision field from a SQL/MX table. The Actual value is 29963.26, however, the value read using the jdbc driver seems to be 29963.260000000002. This seems to be an issue even if I read it as resultset.getString() or resultset.getBigDecimal() because the driver always returns 29963.260000000002.

Similarly, value 99.76 is returned as 99.759999999999. We use CAIL to view the actual value 99.76 from the SQL/MX table, and SQL-Squirrel client and web-app uses sqlmx jdbc driver where we see the value as 99.759999999999

Has anyone faced this or similar issue and have a solution to this problem?


回答1:


I wrapped the double inside of a BigDecimal, then used setscale to 2 digits

BigDecimal.valueOf((resultset.getDouble(<column name here))).setScale(2, RoundingMode.HALF_UP));



来源:https://stackoverflow.com/questions/58841234/hp-nonstop-tandem-t4sqlmx-driver-double-precision-issue

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!