method
round_significant
v5.2.3 -
Show latest stable
- Class:
ActiveSupport::NumberHelper::RoundingHelper
round_significant(number)private
No documentation available.
# File activesupport/lib/active_support/number_helper/rounding_helper.rb, line 35
def round_significant(number)
return 0 if number.zero?
digits = digit_count(number)
multiplier = 10**(digits - precision)
(number / BigDecimal(multiplier.to_f.to_s)).round * multiplier
end