lib/nio/rtnlzr.rb in nio-0.2.2 vs lib/nio/rtnlzr.rb in nio-0.2.3

- old
+ new

@@ -340,11 +340,11 @@ def Rtnlzr.max_denominator(f, max_den=1000000000, num_class=nil) return nil if max_den<1 num_class ||= f.class return mth.ip(f),1 if mth.fp(f)==0 - one = 1.prec(num_class) + one = Nio.numeric_cast(1, num_class) sign = f<0 f = -f if sign a,b,c = 0,1,f @@ -357,10 +357,10 @@ if b>max_den b -= a*mth.ceil((b-max_den)/Float(a)) end - f1,f2 = [a,b].collect{|x| mth.abs(mth.rnd(x*f)/x.prec(num_class)-f)} + f1,f2 = [a,b].collect{|x| mth.abs(mth.rnd(x*f)/Nio.numeric_cast(x, num_class)-f)} a = f1>f2 ? b : a num,den = mth.rnd(a*f).to_i,a den = 1 if mth.abs(den)<1