Menu

Our Calculator Is Exact to 30 Digits. Its "Decimal Preview" Said Zero.
📰

Our Calculator Is Exact to 30 Digits. Its "Decimal Preview" Said Zero.

DEV Community: javascript·fei mai·1 day ago
#XxtRnLdo
#devtojavascript#devto#dev#answer#number
Reading 0:00
15s threshold

The input that broke it was 1,000,000,000. That's not a typo and it's not exotic — it's a billion, the kind of number that shows up in a currency conversion, a population question, a scale factor.

Enter 1 / 1000000000 = c / 1 and leave the third box empty. The calculator answers c = 1/1000000000 , which is correct, exact, and better than most calculators manage. Then, on the line underneath, it adds a decimal preview.

The preview says zero.

How the 77 inputs were built

Our proportion calculator is a static page with no backend. All of the arithmetic lives in one ES module, math.mjs , 264 lines, using BigInt fractions so that a third stays a third. The slope calculator on the sister site imports the exact same file — so a test of one site is a test of both, and so is a bug.

The harness: Node 22.22.0 on Windows, 77 hand-built inputs, five entry modes. Number parsing, solve and check, splitting a total in a ratio, scaling, and the three slope modes.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.