1
votes
circumference :: Float -> Float  
circumference r = 2 * pi * r  

ghci> circumference 4.0  
25.132742 


circumference' :: Double -> Double  
circumference' r = 2 * pi * r 

ghci> circumference' 4.0  
25.132741228718345 

I test this in Haskell.

Here the precision of the Float type is 6 digits. While the precision of the Double type is 15 digits. The precision of the Double type is obviously more than twice of the Float type. Is it still correct to say the Double type is real floating point double the precision of the Float type?

1
I'm not finding it easy to understand what you're asking. Is your question about why it's called a "double-precision floating-point value" if it has more than double the printed characters? If so, note that this is not a Haskell question. Haskell uses the same IEEE-754 single- and double-precision floating-point types as most other languages.Carl
Ok, I think those edits made it a question that can be answered well enough. Probably already has an answer on SO somewhere.Carl

1 Answers

4
votes

As Carl said in the comments, it's more an IEEE-754 question than an Haskell question.

The standard makes a difference between precision and mantissa bits. Precision is the number of bits used to encode your number.

Each IEEE-754 number is made of three elements : a sign, an exponent and a mantissa.

If the sign is always 1 bit, the mantissa and exponent bits do not take proportional bit counts when doubling or quadrupling the precision :

  • for single precision (32 bits), there are 23 mantissa bits for 8 exponent bits.
  • for double precision (64 bits), there are 52 (not 46) mantissa bits for 11 (not 16) exponent bits.

You should also notice that you are comparing precision of the decimal representations. IEEE-754 numbers are fundamentally binary numbers (there exists decimal numbers but that's another story):

  • 1.25[10) = 1.01[2]
  • 1.2[10] = 1.00110011001100110011001100110011...[2]

To go further: