X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=GHC%2FFloat.lhs;h=cac8c0af164770f98753ff95c794ef38a5f29151;hb=42184f4c08e768b391c3d32f65e668fca0eb05a3;hp=41ea69a8b9c9e9c1e75781c73210de9c009ea5a4;hpb=96327b0696bc28551fbdb303506c52b9ee70c95c;p=haskell-directory.git diff --git a/GHC/Float.lhs b/GHC/Float.lhs index 41ea69a..cac8c0a 100644 --- a/GHC/Float.lhs +++ b/GHC/Float.lhs @@ -1,5 +1,5 @@ \begin{code} -{-# OPTIONS -fno-implicit-prelude #-} +{-# OPTIONS_GHC -fno-implicit-prelude #-} ----------------------------------------------------------------------------- -- | -- Module : GHC.Float @@ -16,6 +16,7 @@ #include "ieee-flpt.h" +-- #hide module GHC.Float( module GHC.Float, Float#, Double# ) where import Data.Maybe @@ -188,10 +189,13 @@ instance Num Float where | otherwise = negate 1 {-# INLINE fromInteger #-} - fromInteger n = encodeFloat n 0 - -- It's important that encodeFloat inlines here, and that - -- fromInteger in turn inlines, - -- so that if fromInteger is applied to an (S# i) the right thing happens + fromInteger (S# i#) = case (int2Float# i#) of { d# -> F# d# } + fromInteger (J# s# d#) = encodeFloat# s# d# 0 + -- previous code: fromInteger n = encodeFloat n 0 + -- doesn't work too well, because encodeFloat is defined in + -- terms of ccalls which can never be simplified away. We + -- want simple literals like (fromInteger 3 :: Float) to turn + -- into (F# 3.0), hence the special case for S# here. instance Real Float where toRational x = (m%1)*(b%1)^^n