Skip to content

Commit

Permalink
Added support for arbitrary rounding precision for Ruby < 1.9 as well.
Browse files Browse the repository at this point in the history
  • Loading branch information
ccashwell committed Jan 17, 2013
1 parent 5934c78 commit e25cb0e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/unit/class.rb
Expand Up @@ -183,7 +183,7 @@ def approx
end

def round(precision = 0)
Unit.new(value.round(precision), unit, system)
Unit.new(RUBY_VERSION > '1.9' ? value.round(precision) : ((value * 10**precision).round.to_f / 10**precision), unit, system)
end

def coerce(other)
Expand Down

0 comments on commit e25cb0e

Please sign in to comment.