made it work, more or less, with ruby 1.9
[nyuron.git] / classes / extensions / float.rb
blobb948a6f30f698a4b127ceae7ec4d267c92bb9740
1 class Float
2         if RUBY_VERSION < "1.9"
3                 alias __old_round__ round
4                 ## define round as it is in ruby1.9.
5                 ## the argument specifies the number of digits after zero
6                 def round(x=0)
7                         return self.to_i if x == 0
9                         factor = 10 ** x
10                         (self * factor).__old_round__.to_f / factor
11                 end
12         end
13 end