Class: Float

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

Instance Method Summary collapse

Instance Method Details

#round_up_with_precision(precision = nil) ⇒ Object



5
6
7
# File 'lib/bravo/core_ext/float.rb', line 5

def round_up_with_precision(precision = nil)
  precision.nil? ? round : ((self * (10 ** precision)).round + 1) / (10 ** precision).to_f
end

#round_with_precision(precision = nil) ⇒ Object



2
3
4
# File 'lib/bravo/core_ext/float.rb', line 2

def round_with_precision(precision = nil)
  precision.nil? ? round : (self * (10 ** precision)).round / (10 ** precision).to_f
end