diff --git a/actionpack/lib/action_view/helpers/number_helper.rb b/actionpack/lib/action_view/helpers/number_helper.rb index 7b3751de46..98df5c169b 100644 --- a/actionpack/lib/action_view/helpers/number_helper.rb +++ b/actionpack/lib/action_view/helpers/number_helper.rb @@ -459,8 +459,7 @@ module ActionView raise ArgumentError, ":units must be a Hash or String translation scope." end.keys.map{|e_name| DECIMAL_UNITS.invert[e_name] }.sort_by{|e| -e} - number_exponent = 0 - number_exponent = Math.log10(number).floor if number != 0 + number_exponent = number != 0 ? Math.log10(number).floor : 0 display_exponent = unit_exponents.find{|e| number_exponent >= e } number /= 10 ** display_exponent