Sha256: c24240fb4f168ba68edb0572fc8a5377e0961f8f1a92e8d0a57f95d15357d386

Contents?: true

Size: 428 Bytes

Versions: 270

Compression:

Stored size: 428 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 if RUBY_VERSION < '1.9'

Version data entries

270 entries across 226 versions & 25 rubygems

Version Path
mdg-1.0.1 vendor/bundle/ruby/2.3.0/gems/activesupport-3.2.22.5/lib/active_support/core_ext/float/rounding.rb
activesupport-3.2.22.5 lib/active_support/core_ext/float/rounding.rb
activesupport-3.2.22.4 lib/active_support/core_ext/float/rounding.rb
activesupport-3.2.22.3 lib/active_support/core_ext/float/rounding.rb
activesupport-3.2.22.2 lib/active_support/core_ext/float/rounding.rb
activesupport-3.2.22.1 lib/active_support/core_ext/float/rounding.rb
classiccms-0.7.5 vendor/bundle/gems/activesupport-3.2.3/lib/active_support/core_ext/float/rounding.rb
classiccms-0.7.4 vendor/bundle/gems/activesupport-3.2.3/lib/active_support/core_ext/float/rounding.rb
classiccms-0.7.3 vendor/bundle/gems/activesupport-3.2.3/lib/active_support/core_ext/float/rounding.rb
active_mailer-0.0.10 test/fixtures/dummyapp_rails_3.2/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.12/lib/active_support/core_ext/float/rounding.rb
activesupport-3.2.22 lib/active_support/core_ext/float/rounding.rb
judge-2.0.5 vendor/bundle/ruby/2.1.0/gems/activesupport-3.2.12/lib/active_support/core_ext/float/rounding.rb
activesupport-3.2.21 lib/active_support/core_ext/float/rounding.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/apl-library-0.0.90/vendor/bundle/ruby/1.8/gems/activesupport-3.2.18/lib/active_support/core_ext/float/rounding.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/apl-library-0.0.90/vendor/bundle/ruby/2.1.0/gems/activesupport-3.2.18/lib/active_support/core_ext/float/rounding.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/activesupport-3.2.18/lib/active_support/core_ext/float/rounding.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/apl-library-0.0.90/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.18/lib/active_support/core_ext/float/rounding.rb
apl-library-0.0.90 vendor/bundle/ruby/1.8/gems/activesupport-3.2.18/lib/active_support/core_ext/float/rounding.rb
apl-library-0.0.90 vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.18/lib/active_support/core_ext/float/rounding.rb
activesupport-3.2.20 lib/active_support/core_ext/float/rounding.rb