-
Class float
In a project that I'm working there is an inputText to input float number and to save it into database,
But I had a problem. The inputText was binded into an instance of Class Float in Java language, but when I input some number such as 1234567892 and submit it, it converted into 123456792 into database, and when I read it, it shows 1.23456792E8.
How does it happen? Is there any method to solve this problem to save and show this number as itself(123456789 or 1.23456789E8)?
Thanks
-
Convert the String to BigDecimal and save that instead.
Floating-point types are not adequate for saving decimal numbers with fraction.
Float's precision of only the first 7 positions explains what happened.