Class: Float
- Inherits:
-
Object
- Object
- Float
- Defined in:
- lib/gat/extends.rb
Overview
Float#round_to From: www.hans-eric.com/code-samples/ruby-floating-point-round-off/ Source: – Just round a float number to x decimals
Instance Method Summary collapse
Instance Method Details
#round_to(x) ⇒ Object
72 73 74 |
# File 'lib/gat/extends.rb', line 72 def round_to(x) (self * 10**x).round.to_f / 10**x end |