"how numbers are stored and used in computers"
The purpose of a calculator app is to give correct answers. Floating point numbers are inherently imprecise, so a calculator that relies entirely on floating point arithmetic is like a house built on sand.
BigInt
solves this problem for integersBigInt
valuesCreate a diagram here:
Constructive real numbers are numbers which can be computed to an arbitrary degree of accuracy.
You can't give me every single digit of
code.js1// Leibniz formula: pi/4 = 1 - 1/3 + 1/5 - 1/7 2function pi(tolerance) { 3 let sum = 0; 4 let i = 0; 5 let term = 1; 6 7 while (Math.abs(term) > tolerance) { 8 term = 1 / (2 * i + 1); 9 sum = i % 2 == 0 ? (sum + term) : (sum - term); 10 i++; 11 } 12 13 return sum * 4; 14}