This week's book giveaway is in the Big Data forum.
We're giving away four copies of Elasticsearch in Action and have Radu Gheorghe & Matthew Lee Hinman on-line!
See this thread for details.
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

Win a copy of Elasticsearch in Action this week in the Big Data forum!
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: 244

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: 444

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: 244

Mike Zal
Ranch Hand

Joined: May 04, 2011
Posts: 144

JSTL FMT number example

I agree. Here's the link:
subject: Float precision problem?