Closed jg-rp closed 1 year ago
When using the sum filter on an array containing floats, we get a BigDecimal result, which is rendered in scientific notation.
sum
BigDecimal
require 'liquid' template = Liquid::Template.parse("Result: {{ a | sum }}") puts template.render!({"a" => [0.1, 0.2, 0.3]})
Output
Result: 0.6e0
Expected output
Result: 0.6
For consistency with existing math filters, would it be possible to convert a BigDecimal result to a float, just like the round filter does?
round
https://github.com/Shopify/liquid/blob/77293d4524c55471dd4268ba3a536031c39ee20e/lib/liquid/standardfilters.rb#L791
Many thanks.
When using the
sum
filter on an array containing floats, we get aBigDecimal
result, which is rendered in scientific notation.Output
Expected output
For consistency with existing math filters, would it be possible to convert a
BigDecimal
result to a float, just like theround
filter does?https://github.com/Shopify/liquid/blob/77293d4524c55471dd4268ba3a536031c39ee20e/lib/liquid/standardfilters.rb#L791
Many thanks.