lib/flt/support/rationalizer.rb in flt-1.5.0 vs lib/flt/support/rationalizer.rb in flt-1.5.1
- old
+ new
@@ -113,11 +113,11 @@
def initialize(tol=Tolerance(:epsilon))
@tol = tol
end
def self.[](*args)
- new *args
+ new(*args)
end
# Rationalization method that finds the fraction with
# smallest denominator fraction within the tolerance distance
# of an approximate (floating point) number.
@@ -127,11 +127,11 @@
rationalize_Knuth(x)
end
# This algorithm is derived from exercise 39 of 4.5.3 in
# "The Art of Computer Programming", by Donald E. Knuth.
- def rationalize_Knuth(x)
- rationalization(x) do |x, dx|
+ def rationalize_Knuth(value)
+ rationalization(value) do |x, dx|
x = to_r(x)
dx = to_r(dx)
xp,xq = num_den(x-dx)
yp,yq = num_den(x+dx)