Sha256: c4978118cf8840d3c8d44ecaa2cc6e2d165a3003607d0477573a766c255ea65b

Contents?: true

Size: 404 Bytes

Versions: 53

Compression:

Stored size: 404 Bytes

Contents

class Float
  alias precisionless_round round
  private :precisionless_round

  # Rounds the float with the specified precision.
  #
  #   x = 1.337
  #   x.round    # => 1
  #   x.round(1) # => 1.3
  #   x.round(2) # => 1.34
  def round(precision = nil)
    if precision
      magnitude = 10.0 ** precision
      (self * magnitude).round / magnitude
    else
      precisionless_round
    end
  end
end

Version data entries

53 entries across 53 versions & 4 rubygems

Version Path
social_url_stats-0.0.1 vendor/ruby/1.9.1/gems/activesupport-3.0.0/lib/active_support/core_ext/float/rounding.rb
activesupport-3.0.20 lib/active_support/core_ext/float/rounding.rb
activesupport-3.0.19 lib/active_support/core_ext/float/rounding.rb
activesupport-3.0.18 lib/active_support/core_ext/float/rounding.rb
activesupport-3.0.17 lib/active_support/core_ext/float/rounding.rb
activesupport-3.0.16 lib/active_support/core_ext/float/rounding.rb
activesupport-3.0.15 lib/active_support/core_ext/float/rounding.rb
activesupport-3.0.14 lib/active_support/core_ext/float/rounding.rb
activesupport-3.0.13 lib/active_support/core_ext/float/rounding.rb
activesupport-3.0.13.rc1 lib/active_support/core_ext/float/rounding.rb
activesupport-3.0.12 lib/active_support/core_ext/float/rounding.rb
activesupport-3.0.12.rc1 lib/active_support/core_ext/float/rounding.rb
activesupport-3.0.11 lib/active_support/core_ext/float/rounding.rb
messagebus_ruby_api-0.4.7 spec/ruby/1.9.1/gems/activesupport-3.0.9/lib/active_support/core_ext/float/rounding.rb
messagebus_ruby_api-0.4.4 spec/ruby/1.9.1/gems/activesupport-3.0.9/lib/active_support/core_ext/float/rounding.rb
activesupport-3.0.10 lib/active_support/core_ext/float/rounding.rb
activesupport-3.0.10.rc1 lib/active_support/core_ext/float/rounding.rb
activesupport-3.0.9 lib/active_support/core_ext/float/rounding.rb
activesupport-3.0.9.rc5 lib/active_support/core_ext/float/rounding.rb
activesupport-3.0.9.rc4 lib/active_support/core_ext/float/rounding.rb