Module: Gemmy::Patches::FloatPatch::InstanceMethods::RoundTo

Defined in:
lib/gemmy/patches/float_patch.rb

Instance Method Summary collapse

Instance Method Details

#round_to(n) ⇒ Object

facets i.e. 2.046.round_to(0.01) == 2.05



9
10
11
12
# File 'lib/gemmy/patches/float_patch.rb', line 9

def round_to( n ) #n=1
  return self if n == 0
  (self * (1.0 / n)).round.to_f / (1.0 / n)
end