Skip to content

Commit

Permalink
Handle Infinity and NaN more compatibly.
Browse files Browse the repository at this point in the history
  • Loading branch information
bos committed Aug 6, 2011
1 parent 9d770bd commit 794147e
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions Blaze/Text/Double/Native.hs
Expand Up @@ -32,9 +32,11 @@ float = double . realToFrac

double :: Double -> Builder
double f
| isNaN f || isInfinite f = fromByteString "null"
| isInfinite f = fromByteString $
if f > 0 then "Infinity" else "-Infinity"
| f < 0 || isNegativeZero f = minus `mappend` goGeneric (floatToDigits (-f))
| otherwise = goGeneric (floatToDigits f)
| f >= 0 = goGeneric (floatToDigits f)
| otherwise = fromByteString "NaN"
where
goGeneric p@(T _ e)
| e < 0 || e > 7 = goExponent p
Expand Down

0 comments on commit 794147e

Please sign in to comment.