File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes Float precision problem? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Float precision problem?" Watch "Float precision problem?" New topic

Float precision problem?

mallikarjun dontamsetti
Ranch Hand

Joined: Mar 18, 2011
Posts: 246

I am displaying emp table(oracle) data in jsp the salary column has to display up-to two precision values like 1000.50 or 10000.00

but it is showing like 10000.0 only is there any way to get the data up-to required precision.
Note:I am taking sal column as float in my bean.
Rajkamal Pillai
Ranch Hand

Joined: Mar 02, 2005
Posts: 445

For as similar requirement I used an different getter from the Bean (Value/Form) which would return a String value, currency formatted from the value stored in the respective data member.

Paul Sturrock

Joined: Apr 14, 2004
Posts: 10336

How is your number defined in Oracle? Assuming it allows for at least two decimal points then you can format this how ever you like using the JSTL format tag.

JavaRanch FAQ HowToAskQuestionsOnJavaRanch
mallikarjun dontamsetti
Ranch Hand

Joined: Mar 18, 2011
Posts: 246

Mike Zal
Ranch Hand

Joined: May 04, 2011
Posts: 144

JSTL FMT number example

I agree. Here's the link:
subject: Float precision problem?
It's not a secret anymore!