You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Contrary to the mean(::AbstractArray) method, the mean fallback for general iterables computes the sum without promoting the element type, meaning that overflow can easily happen:
julia>mean([typemax(Int8), typemax(Int8)])
127.0
julia>mean(x for x in [typemax(Int8), typemax(Int8)])
-1.0
Apart from being inconvenient/risky, it's inconsistent with sum:
julia>sum([typemax(Int8), typemax(Int8)])
254
julia>sum(x for x in [typemax(Int8), typemax(Int8)])
254
I think we should use promote_sys_size_add added by #22825 to choose the accumulation type, just like sum.
The text was updated successfully, but these errors were encountered:
Contrary to the
mean(::AbstractArray)
method, themean
fallback for general iterables computes the sum without promoting the element type, meaning that overflow can easily happen:Apart from being inconvenient/risky, it's inconsistent with
sum
:I think we should use
promote_sys_size_add
added by #22825 to choose the accumulation type, just likesum
.The text was updated successfully, but these errors were encountered: