Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Handle Infinity and NaN more compatibly.

  • Loading branch information...
commit 794147e6f0ed6cd10953636bb59ebe3bbde0f20b 1 parent 9d770bd
@bos authored
Showing with 4 additions and 2 deletions.
  1. +4 −2 Blaze/Text/Double/Native.hs
View
6 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
Please sign in to comment.
Something went wrong with that request. Please try again.