Class Float
In: lib/facet/float/approx%3F.rb
lib/facet/float/round_off.rb
lib/facet/float/round_at.rb
lib/facet/float/round_to.rb
Parent: Object

Methods

approx?   round_at   round_to  

External Aliases

round -> round_off
  Alias for round. This is used by both the improved round method and round_to.

Public Instance methods

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

Rounds to the given decimal position.

  require 'facet/float/round'

  4.555.round_at(0)  #=> 5.0
  4.555.round_at(1)  #=> 4.6
  4.555.round_at(2)  #=> 4.56
  4.555.round_at(3)  #=> 4.555

Rounds to the nearest _n_th degree.

  require 'facet/float/round_to'

  4.555.round_to(1)     #=> 5.0
  4.555.round_to(0.1)   #=> 4.6
  4.555.round_to(0.01)  #=> 4.56
  4.555.round_to(0)     #=> 4.555

[Validate]