• 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

Calculating the range of float and double datatypes ?

 
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey Guys,
I wonder how the range of float and double datatypes are calculated actually.

It is obvious that the range for any integer that can be contained in n bits is between -2 raised to (n-1)and (2 raised n-1) -1.

My question is how do we workout such a thing for floating-point types.


__.o^GudLuck for SCJP Aspirants^o.__
 
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For SCJP you don't have to. But remember that int and long can both be converted to float and double with possible loss of precision.
 
Kalyana Sundaram
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hallo Barry Gaunt,
From your answer, May I presume that knowing the range of datatype is not in the SCJP objectives?
But actually What I trying to know from my previous question was the easy formula kindda way to calculate the ranges for the floating-point types like what we have for integral types.
Does Knowing the range Is not really required for SCJP.
Can you help me by giving specific answer for this.
 
reply
    Bookmark Topic Watch Topic
  • New Topic