This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes convert scientific notation number format to normal number format Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "convert scientific notation number format to normal number format" Watch "convert scientific notation number format to normal number format" New topic
Author

convert scientific notation number format to normal number format

dennis laping
Greenhorn

Joined: Nov 06, 2008
Posts: 7
Hi all!

code example:
Float v = 0.0005f;

By default, Java returns the value of v as 5.0E4, right?

Now, what I want is when I call v, it should return the value 0.0005 but not as String. It should still be as Float.
Is this possible?


Thanks,
Dennis
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36453
    
  15
Unless you use the BigDecimal class, there is no such thing as a "format" for a number. It is stored as 32 or 64 bits, which represent the value (or as close as possible) and this doesn't change. You can display the number in any format, probably best done with the % tags in the printf() Formatter#format() and String#format() methods. Start reading in the Java™ Tutorials.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: convert scientific notation number format to normal number format
 
Similar Threads
Wrapper Qu
how to convert to a exact double from float expression
More Dan's exam questions - Wrapper classes
why in float the number 99999999 becomes 1.0E8
Need to convert a float value into a normal value