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

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more