decode (encode NaN) /= NaN
- Dominant language
- Haskell
- Stars
- 120
- Forks
- 70
- PR merge metrics
- No merged PRs in 30d
Description
The IEEE "not-a-number" (NaN) value is not encoded properly, since `encode` uses `decodeFloat`, which is unspecified for NaN (cf. [Prelude](http://hackage.haskell.org/package/base-4.7.0.1/docs/Prelude.html#v:decodeFloat)).
Examples:
``` Haskell
(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
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reading the Haskell binary package's encode and decode entry points, focusing on the Float and Double path that uses decodeFloat. Reproduce the listed NaN examples, then verify that encoding and decoding NaN preserves NaN for both types.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- haskell
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100