Skip to content

Undeflow/overflow warnings for floating-point values

GHC nicely prints overflow warnings for bounded types:

Prelude Data.Word> 232312::Word8

<interactive>:2:1: warning: [-Woverflowed-literals]
    Literal 232312 is out of the Word8 range 0..255
120

But the same courtesy isn't currently extended to floats:

Prelude> 1e5000 :: Float
Infinity
Prelude> 1e-5000 :: Double
0.0

It would be nice if overflow/underflow warnings were issued for floats as well. Note that with the hexadecimal floats proposal (https://github.com/LeventErkok/ghc-proposals/blob/hexFloats/proposals/0000-hexFloats.rst) this would be especially nice, making GHC a very fine platform for numeric computations.

Edited by Levent Erkök
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information