短评 · ·

X 归档 2025-08-31

1 条动态 · 图 1 · 视频 0
ECMAScript excitement 😉

Congrats to @bakkoting on advancing Math.sumPrecise to Stage 4 at TC39 this week 🎉

let vals = [1e20, 0.1, -1e20];
Math.sumPrecise(vals); //👉 0.1

It lets you calculate the sum of an array of numbers. Manual addition in a loop can lose precision.
ECMAScript 好消息 😉

恭喜 @bakkoting 本周在 TC39 将 Math.sumPrecise 推进到 Stage 4 🎉

let vals = [1e20, 0.1, -1e20];
Math.sumPrecise(vals); //👉 0.1

它可以让你计算数字数组的总和。在循环里手动相加可能会丢失精度。
@robpalmer2 的配图 1/1