Class: Numeric

Inherits:
Object
  • Object
show all
Defined in:
lib/benchcc/ext/numeric.rb

Instance Method Summary collapse

Instance Method Details

#round_up(ndigits = 0) ⇒ Object

round_up: Numeric -> Numeric

Round up the integer to a given precision in decimal digits (default 0 digits). This is similar to ‘round`, except that rounding is always done upwards.



7
8
9
10
11
12
13
14
# File 'lib/benchcc/ext/numeric.rb', line 7

def round_up(ndigits = 0)
  k = 10 ** ndigits
  if self % k == 0
    self
  else
    (1 + self/k) * k
  end
end