Is 0.1 + 0.2 equal to 0.3?
In JavaScript or Python, 0.1 + 0.2 gives 0.30000000000000004.
I ran a few more expressions in Node.js and Python:
| Expression | JavaScript / Python | morc calculator |
|---|---|---|
0.1 + 0.2 |
0.30000000000000004 | = 0.3 |
0.1 * 3 |
0.30000000000000004 | = 0.3 |
1.1 * 3 |
3.3000000000000003 | = 3.3 |
10 / 3 * 3 |
10 (the intermediate 10/3 is 3.3333333333333335) | = 10 |
10 / 3 * 3 comes back to 10 only because the rounding in the final multiplication happens to cancel the error. With floating point, whether an error shows up depends on the numbers, and you cannot tell in advance.
This is not a bug. Most computers store numbers as binary floating point, and 0.1 has no exact binary representation, so it is slightly off from the start. That part is well known.
I have been working on a framework I call B13, where every calculation is done with integers, addition, and comparison only. Using that toolkit, I built an everyday scientific calculator.
morc calculator
Code: morc_mini_en.html on GitHub
Calculator: https://codepen.io/morc_b13-bit/pen/01a1ede0-a27b-72f4-ac1c-672a0d815de0
It is one HTML file. Open it in any browser, on a PC or a phone. Nothing is sent over the network; every calculation runs on your device.
You type formulas the way you would in Excel. The answer updates as you type, and Enter (or =) saves it to the history.
Formula syntax (same as Excel)
| You type | Meaning |
|---|---|
=1+2 or 1+2
|
The leading = is optional |
+ - * / ^ % |
Add, subtract, multiply, divide, power, percent (50% is 0.5). × and ÷ also work |
-2^2 is 4 |
As in Excel, a leading minus binds tighter than ^
|
2^3^2 is 64 |
As in Excel, powers are evaluated left to right |
SIN(RADIANS(30)) |
Trig functions use radians; convert degrees with RADIANS
|
Ans key |
Inserts the previous answer |
26 functions are available:
SQRT PI EXP LN LOG10 LOG SIN COS TAN RADIANS DEGREES ROUND ROUNDUP ROUNDDOWN INT ABS MOD QUOTIENT GCD LCM FACT COMBIN POWER SUM PRODUCT AVERAGE
Examples
These are actual outputs of the calculator's engine. "Additions" is the number of additions used to reach the answer.
| Formula | Answer | Tag | Additions |
|---|---|---|---|
=0.1+0.2 |
= 0.3 (fraction 3/10) | exact | 84 |
=1/3*3 |
= 1 | exact | 45 |
=1/7 |
= 0.(142857) (fraction 1/7) | exact | 31 |
=SQRT(16/9) |
= 4/3 | exact | 161 |
=-2^2 |
= 4 | exact | 44 |
=ROUND(-2.5) |
= −3 | exact | 106 |
=200*15% |
= 30 | exact | 145 |
=GCD(1071,462) |
= 21 | exact | 100 |
=123456789*987654321 |
= 121932631112635269 | exact | 443 |
=FACT(30) |
= 265252859812191058636308480000000 | exact | 718 |
=(1+SQRT(5))/2 |
≈ 1.61803398874989484820… | approximate (20 digits) | 65,725 |
=2^0.5 |
≈ 1.41421356237309504880… | approximate (20 digits) | 64,539 |
=EXP(1) |
≈ 2.718281828459045235360287471352… | approximate (30 digits) | 24,704 |
=PI() |
≈ 3.14159265358979323846264338327950288419716939937510… | approximate (50 digits) | 33,927 |
=SIN(RADIANS(30)) shows ≈ 0.50000000000000000000…. The true value is exactly 1/2, but π was cut off at 32 digits along the way, so the result is tagged approximate. The tag honestly carries the fact that a cutoff happened somewhere.
How it works
Every number is kept as integer ÷ integer
0.1 is stored as 1/10 and 0.2 as 1/5. Their sum is 3/10, so the answer is exactly 0.3. 1/7 stays 1/7, so multiplying by 7 gets you back to 1. Every fraction is reduced with the Euclidean algorithm.
For display, the fraction is multiplied by a power of 10, divided, and truncated toward zero at the chosen number of digits. Repeating decimals show the repeating part in parentheses.
Multiplication and division from addition
Inside, the only operations on numbers are adding and comparing which is larger.
- Subtraction: flip the sign and add.
- Multiplication a×b: add a to itself to build a ladder a, 2a, 4a, 8a, …; split b into rungs 1, 2, 4, 8, … and add up the matching rungs of a.
- Division a÷b: build the ladder b, 2b, 4b, …; from the top, subtract every rung that fits. The rungs you used add up to the quotient; what is left is the remainder.
- Times 10: build 2x, 4x, 8x by addition, then 8x + 2x.
- Square root: try adding 1, 2, 4, … (from the top rung down) to the candidate, and keep each one if its square does not exceed the number.
The "ladder" is just long multiplication done in binary.
Numbers that never end are tagged "approximate"
For √2, π, e, LN, SIN and other values whose decimals never terminate, the calculator works with integers scaled by a power of 10. It computes 12 more digits than requested, cuts off, and tags the result as approximate.
- π comes from 16·atan(1/5) − 4·atan(1/239), with every term added or subtracted as an integer.
- EXP sums 1 + x + x²/2! + …; LN splits the number into a power of 2 and a value between 1 and 2, then sums a series.
- SIN and COS fold the angle into one turn of 2π, then sum their series.
If any approximation enters a formula, the answer is tagged approximate. Anything that can be written as a fraction is tagged exact.
Balanced number systems
A collapsible panel shows the same answer in balanced ternary (digits −1, 0, +1) and balanced base 13 (digits −6 to +6). Answers with decimals get a radix point there too.
For example, −1/7 in balanced base 13 is 0.(−2)(+2)(−2)(+2)…. Summing that pattern, which starts at −2/13, gives exactly −1/7.
Verification
I fixed the pass criteria before running anything:
- Exact formulas: pass if the fraction matches exactly and the tag is "exact".
- Approximate formulas: pass if the result is within 1 in the 38th decimal place of mpmath (80-digit precision) and the tag is "approximate".
- Invalid formulas: pass if the calculator returns an error message instead of an answer. Returning an answer is a fail.
- Balanced digits: pass if converting the digits back to a number lands within half of the last digit.
| Item | Cases | Result |
|---|---|---|
Exact formulas (arithmetic, %, -2^2, 2^3^2, ROUND halves, MOD and QUOTIENT with negatives, …) |
28 | all pass |
| Approximate formulas (π, e, EXP, LN, LOG, SIN, COS, TAN, fractional powers, …) | 18 | all pass |
| Invalid formulas (divide by zero, missing parenthesis, unknown function, LN(0), …) | 7 | all pass |
| Balanced ternary and balanced base 13 (π, √2, −e, 22/7, 0.1+0.2, −1/7, −12345) | 14 | all pass |
A smaller tool built from the same engine (below) was also checked independently by another AI (ChatGPT): multiplication over every pair from −100 to 100, division over every pair from −30 to 30, square roots for 0 to 10,000, and balanced digits for −10,000 to 10,000 all passed, and π, e, √2 and φ matched external values to 200 digits.
Counting the additions: morc mini
Code: morc_mini_en.html on GitHub
Mini: https://codepen.io/morc_b13-bit/pen/01a1f115-ce16-720d-b8f7-b1ac52ff36cc
This small version is for watching how many additions an answer takes. When it opens, sample calculations play one after another.
- 123456789 × 987654321: 93 additions
- 2 to the 100th power: 363 additions
- π to 50 decimal places: 30,542 additions
- π to 100 decimal places: 103,828 additions
Doubling the digits of π makes the additions grow about 3.4 times, because both the number of terms and the length of each term increase.
Where it comes from
The calculator is an appendix to my book Nature Knows Only Addition — Mathematics by Addition Alone, in Moving Figures (in Japanese, free on Zenn). In the book I build each tool one at a time with addition only; the calculator puts them together for everyday use.
https://zenn.dev/link/books/1300fdf2e0ddf7
The code for the book and the calculator lives in the B13-Library repository on GitHub under the MIT License. Use it, change it, and share it freely.
https://github.com/morcb13-bit/B13-Library
Summary
With floating point, 0.1 + 0.2 and 1.1 × 3 drift in the last digit, while 10 / 3 × 3 happens to come back. Whether an error appears depends on the numbers. If you keep every number as a fraction and limit the operations to addition and comparison, every result lands exactly. 0.1 + 0.2 is exactly 0.3, and 1/7 times 7 is exactly 1. Numbers that never end, such as π and √2, are cut off at the digits you choose, and the calculator says so with a tag.
Because it carries "exact" and "approximate" separately, the answer itself tells you how far you can trust it. A scientific calculator built from addition alone, with Excel-style formulas, running in any browser and on your phone.

Top comments (0)