Meaningless Drivel is fun!*
The moose likes JDBC 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
Bookmark "Float precision problem?" Watch "Float precision problem?" New topic
Author

Float precision problem?

mallikarjun dontamsetti
Ranch Hand

Joined: Mar 18, 2011
Posts: 242

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: 443
    
    1


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
Bartender

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

Number(8,2)
Mike Zal
Ranch Hand

Joined: May 04, 2011
Posts: 144

JSTL FMT number example


OCJP6, OCWCD5
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Float precision problem?
 
Similar Threads
simple question
Wrappers and floats comparision
Marcus Green Exam 3, Q 1
Not Getting Compilation Error?
whats the difference between float & double