Published
Edited
Jul 10, 2018
1 star
Insert cell
Insert cell
Insert cell
Insert cell
/*
* Repeatedly halves the number 1 right until doing so causes the number to collapse to 0
*/
function computeMinimum() {
let minimum = 1.0;
while(minimum / 2 > 0) minimum /= 2;
return minimum;
}
Insert cell
Insert cell
// A demonstration of a breaking point of floating point arithmetic
computeMinimum() - 0.01
Insert cell
Insert cell
/*
* Repeatedly doubles the number 1 right until doing so causes the number to explode to infinity
*/
function computeMaximum() {
let maximum = 1.0;
while(maximum * 2 != Infinity) maximum *= 2;
return maximum;
}
Insert cell
Insert cell
// A demonstration of a breaking point of floating point arithmetic
computeMaximum() + 1
Insert cell
Insert cell
Insert cell
function computeEpsilon() {
let epsilon = 1.0;
while(!(1 + epsilon == 1)) epsilon /= 2;
return epsilon;
}
Insert cell
Insert cell
// A demonstration of a breaking point of floating point arithmetic
1 + computeEpsilon()
Insert cell
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