From 794147e6f0ed6cd10953636bb59ebe3bbde0f20b Mon Sep 17 00:00:00 2001 From: Bryan O'Sullivan Date: Sat, 6 Aug 2011 12:01:31 -0700 Subject: [PATCH] Handle Infinity and NaN more compatibly. --- Blaze/Text/Double/Native.hs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Blaze/Text/Double/Native.hs b/Blaze/Text/Double/Native.hs index b979339..51b36e7 100644 --- a/Blaze/Text/Double/Native.hs +++ b/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