Closed michaelficarra closed 3 months ago
I'm guessing this was left over from a version that took an iterator?
Not a leftover, yes an intentional decision so that the iterable-taking version could work the same way. Since that's observable (unless we get rid of the ToNumber
calls) I'm inclined to leave it as-is.
Also, do we really need to do this in Math.sum? It seems like if we're going to do this anywhere, we should make it apply everywhere.
We need to do this in Math.sum
because at least a couple of the reasonable algorithms for handling arbitrary-precision arithmetic can overflow if fed more than 2**53 values. That's not true for e.g. Math.max
.
I guess we could leave it out and just assume implementations are OK with violating the spec in that case? But it seems better to specify somehow.
I don't think we need to mirror the algorithms that closely. Also, if we're just calling ToNumber for consistency with Math.min/max, I don't think that's great motivation either.
This isn't relevant any longer because the API does take an iterator now.
I'm guessing this was left over from a version that took an iterator?
Also, do we really need to do this in
Math.sum
? It seems like if we're going to do this anywhere, we should make it apply everywhere.