Class: Float

Inherits:
Object
  • Object
show all
Defined in:
lib/gin/core_ext/float.rb

Instance Method Summary collapse

Instance Method Details

#round(ndigits = 0) ⇒ Object


4
5
6
7
8
# File 'lib/gin/core_ext/float.rb', line 4

def round ndigits=0
  num, dec = self.to_s.split(".")
  num = "#{num}.#{dec[0,ndigits]}".sub(/\.$/, "")
  Float num
end