forked from fixin.me/fixin.me
Rake task to export default settings as seeds
This commit is contained in:
14
lib/core_ext/big_decimal/formatting.rb
Normal file
14
lib/core_ext/big_decimal/formatting.rb
Normal file
@@ -0,0 +1,14 @@
|
||||
module FixinMe
|
||||
module BigDecimalScientificNotation
|
||||
def to_scientific
|
||||
return 'NaN' unless finite?
|
||||
|
||||
sign, coefficient, base, exponent = split
|
||||
(sign == -1 ? '-' : '') +
|
||||
(coefficient.length > 1 ? coefficient.insert(1, '.') : coefficient) +
|
||||
(exponent != 1 ? "e#{exponent-1}" : '')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
BigDecimal.prepend(FixinMe::BigDecimalScientificNotation)
|
||||
Reference in New Issue
Block a user