Method: Float#round_at
- Defined in:
- lib/core/facets/numeric/round.rb
#round_at(d) ⇒ Object
Rounds to the given decimal position.
4.555.round_at(0) #=> 5.0
4.555.round_at(1) #=> 4.6
4.555.round_at(2) #=> 4.56
4.555.round_at(3) #=> 4.555
CREDIT: Trans
50 51 52 |
# File 'lib/core/facets/numeric/round.rb', line 50 def round_at( d ) #d=0 (self * (10.0 ** d)).round.to_f / (10.0 ** d) end |