• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

convert scientific notation number format to normal number format

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
reply
    Bookmark Topic Watch Topic
  • New Topic