Skip to content
Snippets Groups Projects
Commit 0d7354ee authored by sof's avatar sof
Browse files

[project @ 1997-03-20 17:38:23 by sof]

Improved showFloat (catches NaN and Inf)
parent ed512fa7
No related merge requests found
......@@ -941,6 +941,13 @@ point type to obtain the same results.
{-# GENERATE_SPECS showFloat a{Double#,Double} #-}
showFloat:: (RealFloat a) => a -> ShowS
showFloat x =
if isNaN x then showString "NaN"
else if isInfinite x then
( if x < 0 then showString "-" else id) . showString "Infinite"
else if x < 0 || isNegativeZero x then showChar '-' . showFloat' (-x) else showFloat' x
showFloat' :: (RealFloat a) => a -> ShowS
showFloat' x =
if x == 0 then showString ("0." ++ take (m-1) zeros)
else if e >= m-1 || e < 0 then showSci else showFix
where
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment