Sha256: d3ea64e737bf9ddb1371c469c2b8622ad4fb6d35586c89b32631d94f73c835fc

Contents?: true

Size: 302 Bytes

Versions: 4

Compression:

Stored size: 302 Bytes

Contents

class Float
  # 3 following methods from http://www.hans-eric.com/code-samples/ruby-floating-point-round-off/
  def round_to(x)
    (self * 10**x).round.to_f / 10**x
  end

  def ceil_to(x)
    (self * 10**x).ceil.to_f / 10**x
  end

  def floor_to(x)
    (self * 10**x).floor.to_f / 10**x
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
mspire-0.4.9 lib/core_extensions.rb
mspire-0.4.4 lib/core_extensions.rb
mspire-0.4.5 lib/core_extensions.rb
mspire-0.4.7 lib/core_extensions.rb