Sha256: 5c58ab4e467841fc1593074dbb6b7d3596a4d79d11156af185674cf17c121dd1

Contents?: true

Size: 313 Bytes

Versions: 7

Compression:

Stored size: 313 Bytes

Contents

# frozen_string_literal: true

# Taken from http://www.programmingishard.com/posts/show/128
# Posted by rbates
class Float
  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

7 entries across 7 versions & 1 rubygems

Version Path
activerecord-import-2.0.0 benchmarks/lib/float.rb
activerecord-import-1.8.1 benchmarks/lib/float.rb
activerecord-import-1.8.0 benchmarks/lib/float.rb
activerecord-import-1.6.0 benchmarks/lib/float.rb
activerecord-import-1.5.1 benchmarks/lib/float.rb
activerecord-import-1.5.0 benchmarks/lib/float.rb
activerecord-import-1.4.1 benchmarks/lib/float.rb