Skip to content

Numeric.floatToDigits fails for large floatRange

I tried to write some high precision floating point datatype like this (corresponding to encodeFloat and decodeFloat format):

data HugeFloat = HugeFloat Integer Int

Mainly as an exercise to see how much slower it would be, but got failures trying to print the values (ghci would consume all available memory and be rather unresponsive w.r.t. ctrl-C input).

Changing this line in my RealFloat instance from:

  floatRange _ = (minBound, maxBound) -- fails

to:

  floatRange _ = (minBound `div` 2, maxBound `div` 2) -- works

made the non-termination failures seemingly disappear.

With attached code, ghci fails if I type:

  > 771 :: F1
Trac metadata
Trac field Value
Version 6.12.3
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component libraries/base
Test case
Differential revisions
BlockedBy
Related
Blocking
CC claudiusmaximus@goto10.org
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information