• 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

floating point value

 
Ranch Hand
Posts: 270
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Technically speaking, what does floating point value mean?
Is double a "floating point value" also? If yes, why?
For example, if a method returns a floating point value, is it safe to assume that it is returning a float?
Thanks,
Cathy.
 
Ranch Hand
Posts: 456
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
a floating point value is always a decimal eg 1.15, 10.0, 0.93, -25.0
It can be either double or float. The term floating point has to do with the fact that the decimal point "floats" it is not always in the same place. With a non-floating point value such as int the decimal point is always in the same place, to the right of all the values.
10 = non floating point
10.0 = floating point
A method that returns a floating point value returns either a float or a double, you do not have enough info to say for sure with just floating point value as the description.
 
Cathy Song
Ranch Hand
Posts: 270
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Damien,
Thanks for clearing my doubt.
--Cathy.
 
Ranch Hand
Posts: 197
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Basically you only have the 32 or 64 bits (with float & double) to play with to give a certain level of accuracy. If the decimal point was fixed, a lot of the time it would make the most significant bits redundant eg 000010.567 so the point 'floats' as far left as it can ie 10.5672345, and thus gives the greatest accuracy using the remaining bits. It actually manages this my having an exponent part to the bit pattern, which tells it the magnitude of the number.
reply
    Bookmark Topic Watch Topic
  • New Topic