X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=GHC%2FFloat.lhs;h=02aba8ca85f3fea261f8e8d3f22fa7f7787b37c0;hb=41e8fba828acbae1751628af50849f5352b27873;hp=aa2a5344efd5cc81a2f210f711f3545b722c1bb9;hpb=a08bde2941df4518fe2377920804404903a7daa8;p=ghc-base.git diff --git a/GHC/Float.lhs b/GHC/Float.lhs index aa2a534..02aba8c 100644 --- a/GHC/Float.lhs +++ b/GHC/Float.lhs @@ -1,9 +1,15 @@ \begin{code} -{-# OPTIONS_GHC -XNoImplicitPrelude #-} +{-# LANGUAGE CPP + , NoImplicitPrelude + , MagicHash + , UnboxedTuples + , ForeignFunctionInterface + #-} -- We believe we could deorphan this module, by moving lots of things -- around, but we haven't got there yet: {-# OPTIONS_GHC -fno-warn-orphans #-} {-# OPTIONS_HADDOCK hide #-} + ----------------------------------------------------------------------------- -- | -- Module : GHC.Float @@ -600,7 +606,7 @@ floatToDigits base x = if e >= 0 then let be = expt b e in if f == expt b (p-1) then - (f*be*b*2, 2*b, be*b, b) + (f*be*b*2, 2*b, be*b, be) -- according to Burger and Dybvig else (f*be*2, 2, be, be) else @@ -785,11 +791,20 @@ expt base n = if base == 2 && n >= minExpt && n <= maxExpt then expts!n else - base^n + if base == 10 && n <= maxExpt10 then + expts10!n + else + base^n expts :: Array Int Integer expts = array (minExpt,maxExpt) [(n,2^n) | n <- [minExpt .. maxExpt]] +maxExpt10 :: Int +maxExpt10 = 324 + +expts10 :: Array Int Integer +expts10 = array (minExpt,maxExpt10) [(n,10^n) | n <- [minExpt .. maxExpt10]] + -- Compute the (floor of the) log of i in base b. -- Simplest way would be just divide i by b until it's smaller then b, but that would -- be very slow! We are just slightly more clever.