[commit: base] master: Use Rational constructor if numerator or denominator is 1 (339aaab)
Daniel Fischer
dafis at galois.com
Tue Oct 4 20:21:48 CEST 2011
Repository : ssh://darcs.haskell.org//srv/darcs/packages/base
On branch : master
http://hackage.haskell.org/trac/ghc/changeset/339aaabd3377cbaece7424c7cc29a955915abb93
>---------------------------------------------------------------
commit 339aaabd3377cbaece7424c7cc29a955915abb93
Author: Daniel Fischer <daniel.is.fischer at googlemail.com>
Date: Tue Oct 4 17:17:31 2011 +0200
Use Rational constructor if numerator or denominator is 1
>---------------------------------------------------------------
GHC/Float.lhs | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/GHC/Float.lhs b/GHC/Float.lhs
index 13246ac..38365fa 100644
--- a/GHC/Float.lhs
+++ b/GHC/Float.lhs
@@ -853,7 +853,7 @@ fromRat' x = r
p0 = (integerLogBase b (numerator x) - integerLogBase b (denominator x) - p) `max` minExp
-- if x = n/d and ln = integerLogBase b n, ld = integerLogBase b d,
-- then b^(ln-ld-1) < x < b^(ln-ld+1)
- f = if p0 < 0 then 1 % expt b (-p0) else expt b p0 % 1
+ f = if p0 < 0 then 1 :% expt b (-p0) else expt b p0 :% 1
x0 = x / f
-- if ln - ld >= minExp0, then b^(p-1) < x0 < b^(p+1), so there's at most
-- one scaling step needed, otherwise, x0 < b^p and no scaling is needed
More information about the Cvs-libraries
mailing list