Public
Edited
Oct 24, 2023
Importers
11 stars
Insert cell
Insert cell
1 + 1e-14 - 1 // 🌶
Insert cell
d3.fsum([1, 1e-14, -1]) // 👍
Insert cell
d3.sum([1, -2e-17, -1]) // 🌶
Insert cell
d3.fsum([1, -2e-17, -1]) // 👍
Insert cell
Insert cell
Insert cell
d3.fsum([.1, NaN, undefined, .1, .1, .1, .1, .1, .1, .1, .1, .1])
Insert cell
d3.sum([.1, NaN, undefined, .1, .1, .1, .1, .1, .1, .1, .1, .1])
Insert cell
Insert cell
d3.fsum(new Set([{a: .1}, {a: .2}, {a: .3}, {a: .4}, {a: -1}]), d => d.a)
Insert cell
Insert cell
Insert cell
.1 + .1 + .1
Insert cell
d3.fsum([.1, .1, .1])
Insert cell
Insert cell
a = {
const a = new d3.Adder();
for (let i = 0; i < 3; i++) {
a.add(.01);
}
return a
}
Insert cell
a.valueOf()
Insert cell
+a // the + notation is a JavaScript shorthand notation for the valueOf method
Insert cell
Insert cell
Insert cell
test(d3.sum, 1000)
Insert cell
test(d3.fsum, 1000)
Insert cell
async function test(sum, delay) {
await Promises.delay(delay || 0)
const N = 10;

const t = performance.now();
for (let i = 0; i < N; i++) sum(M);
return (performance.now() - t) / N;
}
Insert cell
M = Float64Array.from({ length: 1e6 }, Math.random)
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more