binary icon indicating copy to clipboard operation
binary copied to clipboard

decode (encode NaN) /= NaN

Open Flupp opened this issue 10 years ago • 0 comments

The IEEE "not-a-number" (NaN) value is not encoded properly, since encode uses decodeFloat, which is unspecified for NaN (cf. Prelude).

Examples:

(0 / 0 :: Double) = NaN
(decode (encode (0 / 0 :: Double)) :: Double) = -Infinity
(log (-1) :: Double) = NaN
(decode (encode (log (-1) :: Double)) :: Double) = Infinity
(0 / 0 :: Float) = NaN
(decode (encode (0 / 0 :: Float)) :: Float) = -Infinity

Flupp avatar Dec 16 '14 10:12 Flupp