Determines if another number is approximately equal within a given _n_th degree. Defaults to 100ths if the degree is not specified.
CREDIT: Trans
# File lib/facets/core/facets/numeric/approx.rb, line 9 def approx?(x, n=0.01) return(self == x) if n == 0 (self - x).abs <= n end
Returns self, useful for polymorphic cases.
# File lib/facets/core/facets/numeric/length.rb, line 5 def length self end
Conceptually, rounding is expected to apply to floating point numbers. However it can actually be applied to pretty much any Numeric object. For example, one could round an Integer to the nearest kilo.
See Float#round_at.
# File lib/facets/core/facets/numeric/round.rb, line 9 def round_at(*args) to_f.round_at(*args) end
See Float#round_to.
# File lib/facets/core/facets/numeric/round.rb, line 15 def round_to(*args) to_f.round_to(*args) end