haddock attributes for haddock-2.0
[ghc-base.git] / GHC / Float.lhs
index 9831ec9..ff40906 100644 (file)
@@ -1,5 +1,6 @@
 \begin{code}
 {-# OPTIONS_GHC -fno-implicit-prelude #-}
+{-# OPTIONS_HADDOCK hide #-}
 -----------------------------------------------------------------------------
 -- |
 -- Module      :  GHC.Float
@@ -16,6 +17,7 @@
 
 #include "ieee-flpt.h"
 
+-- #hide
 module GHC.Float( module GHC.Float, Float#, Double# )  where
 
 import Data.Maybe
@@ -41,7 +43,7 @@ infixr 8  **
 -- | Trigonometric and hyperbolic functions and related functions.
 --
 -- Minimal complete definition:
---      'pi', 'exp', 'log', 'sin', 'cos', 'sinh', 'cosh'
+--      'pi', 'exp', 'log', 'sin', 'cos', 'sinh', 'cosh',
 --      'asin', 'acos', 'atan', 'asinh', 'acosh' and 'atanh'
 class  (Fractional a) => Floating a  where
     pi                 :: a
@@ -188,10 +190,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
@@ -627,8 +632,10 @@ floatToDigits base x =
       (f*b*2, b^(-e+1)*2, b, 1)
     else
       (f*2, b^(-e)*2, 1, 1)
+  k :: Int
   k =
    let 
+    k0 :: Int
     k0 =
      if b == 2 && base == 10 then
         -- logBase 10 2 is slightly bigger than 3/10 so