Class: Float

Inherits:
Object
  • Object
show all
Defined in:
lib/floatstats.rb

Overview

format

Instance Method Summary collapse

Instance Method Details

#r_to(x) ⇒ Object



4
5
6
7
# File 'lib/floatstats.rb', line 4

def r_to(x)
  num = (self * 10**x).round.to_f / 10**x
  sprintf("%.#{x}f", num)
end