Class: Float
Overview
File lib/core/facets/float/round.rb, line 17 def round_at( d ) #d=0
(self * (10.0 ** d)).round.to_f / (10.0 ** d)
end
Instance Method Summary collapse
-
#truncate_with_precision(d) ⇒ Object
This is the same as round_at except instead of rounding (up or down) to the nearest integer, it always truncates, rounding down to the next lowest integer.
Instance Method Details
#truncate_with_precision(d) ⇒ Object
This is the same as round_at except instead of rounding (up or down) to the nearest integer, it always truncates, rounding down to the next lowest integer.
36 37 38 |
# File 'lib/quality_extensions/float/truncate.rb', line 36 def truncate_with_precision(d) (self * (10.0 ** d)).truncate_without_precision.to_f / (10.0 ** d) end |