This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
I want to display a large number to jsp reading from database(Oracle).The number is "1111111111". The number in database is "1111111111" excactly and it is Float (126) . But after it displayed to jsp,it become "1111111112" ?! why JVM auto format Float number? The number "1111111112" is not what I want to see. I use NumberFormat class to format it,but no luck ;-(
My code is:
If I input number 300000000,it will display 3E. no! Why it couldn't display correctly? How to format large number for display correctly? Thks!! :roll: [ January 13, 2005: Message edited by: Bear Bibeault ]
The problem isn't with formatting; it's with the way floating point numbers are stored internally. Floats are not exact and introduce round-off error. If you want information, you can google or use the search tool here at the Ranch. To make things short here, though, I'll just suggest that you use the BigInteger class in order to store an exact representation of the number.