diff options
author | José Valim <jose.valim@gmail.com> | 2012-03-27 03:05:11 -0700 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2012-03-27 03:05:11 -0700 |
commit | 19901c6c61d1900a1452c8b14943a8345463f039 (patch) | |
tree | 3be320a810ac68ed8e993fdd78fec9f4c532620e /actionpack/lib/action_view | |
parent | ded74dfd8b68153a2eec2a6c2bcee3c6e43bb91b (diff) | |
parent | 7051a234b7b2f6d7db5b29b3afc7167a8b6db991 (diff) | |
download | rails-19901c6c61d1900a1452c8b14943a8345463f039.tar.gz rails-19901c6c61d1900a1452c8b14943a8345463f039.tar.bz2 rails-19901c6c61d1900a1452c8b14943a8345463f039.zip |
Merge pull request #5609 from tjmcewan/master
prevent returning a negative zero from number_with_precision
Diffstat (limited to 'actionpack/lib/action_view')
-rw-r--r-- | actionpack/lib/action_view/helpers/number_helper.rb | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/actionpack/lib/action_view/helpers/number_helper.rb b/actionpack/lib/action_view/helpers/number_helper.rb index b0860f87c4..485a9357be 100644 --- a/actionpack/lib/action_view/helpers/number_helper.rb +++ b/actionpack/lib/action_view/helpers/number_helper.rb @@ -292,6 +292,7 @@ module ActionView precision = precision > 0 ? precision : 0 #don't let it be negative else rounded_number = BigDecimal.new(number.to_s).round(precision).to_f + rounded_number = rounded_number.zero? ? rounded_number.abs : rounded_number #prevent showing negative zeros end formatted_number = number_with_delimiter("%01.#{precision}f" % rounded_number, options) if strip_insignificant_zeros |