Permalink
Browse files

Handle Infinity and NaN more compatibly.

  • Loading branch information...
1 parent 9d770bd commit 794147e6f0ed6cd10953636bb59ebe3bbde0f20b @bos committed Aug 6, 2011
Showing with 4 additions and 2 deletions.
  1. +4 −2 Blaze/Text/Double/Native.hs
@@ -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

0 comments on commit 794147e

Please sign in to comment.