Sha256: 3198439f20ecc825bfe03791af5a127a022164b7d889a2fdf6844939915aabb3

Contents?: true

Size: 275 Bytes

Versions: 16

Compression:

Stored size: 275 Bytes

Contents

class Numeric

  # Determines if another number is approximately equal
  # within a given _n_th degree. Defaults to 100ths
  # if the degree is not specified.
  #
  # CREDIT: Trans

  def approx?(x, n=0.01)
    return(self == x) if n == 0
    (self - x).abs <= n
  end

end

Version data entries

16 entries across 15 versions & 1 rubygems

Version Path
facets-2.9.2 lib/core/facets/numeric/approx.rb
facets-2.9.2 src/core/facets/numeric/approx.rb
facets-2.9.1 lib/core/facets/numeric/approx.rb
facets-2.9.0 lib/core/facets/numeric/approx.rb
facets-2.9.0.pre.2 lib/core/facets/numeric/approx.rb
facets-2.9.0.pre.1 lib/core/facets/numeric/approx.rb
facets-2.8.4 lib/core/facets/numeric/approx.rb
facets-2.8.3 lib/core/facets/numeric/approx.rb
facets-2.8.2 lib/core/facets/numeric/approx.rb
facets-2.8.1 lib/core/facets/numeric/approx.rb
facets-2.8.0 lib/core/facets/numeric/approx.rb
facets-2.7.0 lib/core/facets/numeric/approx.rb
facets-2.6.0 lib/core/facets/numeric/approx.rb
facets-2.5.1 lib/core/facets/numeric/approx.rb
facets-2.5.0 lib/core/facets/numeric/approx.rb
facets-2.5.2 lib/core/facets/numeric/approx.rb