1
module ActiveSupport #:nodoc:
2
module CoreExtensions #:nodoc:
5
def self.included(base) #:nodoc:
7
alias_method :round_without_precision, :round
8
alias_method :round, :round_with_precision
12
# Rounds the float with the specified precision.
17
# x.round(2) # => 1.34
18
def round_with_precision(precision = nil)
19
precision.nil? ? round_without_precision : (self * (10 ** precision)).round / (10 ** precision).to_f