我使用Ruby 2.2.3和Rails 4.2.3。我用下面的代碼獲得一個NoMemoryError: failed to allocate memory
在IRB控制檯:NoMemoryError:未能使用BigDecimal .to_s方法分配內存
# Using 123e+1000000000000000000
BigDecimal('123e+1000000000000000000').to_s
#=> NoMemoryError: failed to allocate memory
但這個例子有更多更大的作品數量:
# Using 123e+1000000000000000000000000000000000
BigDecimal('123e+1000000000000000000000000000000000').to_s
#=> "Infinity"
這裏的BigDecimal
代碼:https://github.com/rails/rails/blob/v4.2.3/activesupport/lib/active_support/core_ext/big_decimal/conversions.rb
你的問題是? – sawa