• 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

float display : shows scientific

 
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a float in the database , when i enter a big value it starts showing in scientific notation.
so : 50000000 shows as 5.0e8.
Eventhough the db has 50000000. Whats the fastest way to convert it into 50000000 inside my javabean from 5.0e8
 
Ranch Hand
Posts: 399
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Java has only one way of storing real numbers (float or double), which follows the IEEE 754 specification. So "500000000" and "5.0e8" are not different numbers, but simply different ways of displaying (formatting) the same number.
If you don't like how a number is displayed, you can use the "java.text.DecimalFormat" class to control it. Look at this example:

When run, it displays:
Float 1: 8.0E7
Float 2: 8.0E7
Float 1: 80000000
Float 2: 80000000
Float 1: 80000000.0000000000
Float 2: 80000000.0000000000
So you can see that both "80000000F" and "8.0e7F" are the same number as far as Java is concerned. If you don't like how it get printed out, change it.
 
reply
    Bookmark Topic Watch Topic
  • New Topic