Class | Numeric
In: | lib/core/facets/boolean.rb lib/core/facets/kernel/blank.rb lib/core/facets/numeric/approx.rb lib/core/facets/numeric/distance.rb lib/core/facets/numeric/length.rb lib/core/facets/numeric/round.rb lib/core/facets/numeric/spacing.rb lib/core/facets/object/dup.rb lib/standard/facets/random.rb lib/supplemental/facets/multipliers.rb
Parent: | Object

### Methods

approx? blank? clone? distance dup! dup? length round_at round_to spacing to_b

### Included Modules

Random::NumericExtensions Multipliers

### Classes and Modules

Module Numeric::Multipliers

### Public Instance methods

approx?(x, n=0.01)

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

CREDIT: Trans

blank?()
clone?()
distance(other)

Returns the distance between self an another value. This is the same as #- but it provides an alternative for common naming between variant classes.

      4.distance(3)  #=> 1

dup!()

Since Numeric is immutable it cannot be duplicated. For this reason try_dup returns `self`.

      1.dup!  #=> 1

dup?()
length()

Returns `self`, useful for polymorphic cases.

round_at(*args)

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.

round_to(*args)

See Float#round_to.

spacing()

Returns the size of the string representation of a numerical value.

         1.spacing   #=> 1
        10.spacing   #=> 2
       100.spacing   #=> 3
      -100.spacing   #=> 4
       1.2.spacing   #=> 3

CREDIT: Victor H. Goff III

to_b()

Provides a boolean interpretation of self. If self == 0 then false else true.

      0.to_b    #=> false
      1.to_b    #=> true
      2.3.to_b  #=> true

[Validate]