RosettaCodeData/Task/Infinity/Haskell/infinity-1.hs

9 lines
252 B
Haskell
Raw Permalink Normal View History

2013-04-10 12:38:42 -07:00
maxRealFloat :: RealFloat a => a -> a
maxRealFloat x = encodeFloat b (e-1) `asTypeOf` x where
b = floatRadix x - 1
(_,e) = floatRange x
infinity :: RealFloat a => a
infinity = if isInfinite inf then inf else maxRealFloat 1.0 where
inf = 1/0