Scientific Calculator
Basic, scientific and programmer calculator in one page: trig, logs, factorials, HEX/BIN/OCT bitwise maths and a history of your last 20 results.
The interactive tool loads here when JavaScript runs.
About this toolWhat is the Scientific Calculator?
This calculator has three modes on tabs. Basic covers the four operations, percent, sign change and five memory keys (MC, MR, M+, M-, MS). Scientific adds sin, cos, tan and their inverses, log, ln, square root, x², x^y, 10^x, factorial, abs, mod, parentheses and the constants π and e. Programming works on whole numbers in HEX, DEC, OCT or BIN and adds AND, OR, XOR, NOT and bit shifts.
Expressions are evaluated by the mathjs library, not by JavaScript eval, so 2 + 3 × 4 gives 14 and 2^3^2 gives 512 (power is right-associative). Results are rounded to 14 significant digits for display, which is why 0.1 + 0.2 shows 0.3 here instead of the 0.30000000000000004 you get in a browser console.
Everything runs in your browser. The history panel keeps your last 20 calculations for the current visit only; it is not saved when you close the tab.
- Basic, Scientific and Programming modes on one page
- Expressions evaluated by mathjs with correct precedence, no eval
- HEX, DEC, OCT and BIN readouts with AND, OR, XOR, NOT and shifts
- Five memory keys and a clickable 20-item history
- Keyboard input for digits, operators, Enter, Backspace and Esc
- Runs entirely in your browser
Updated
How to use the Scientific Calculator
- Pick Basic, Scientific or Programming on the tab bar above the keypad.
- Enter numbers with the keypad or your keyboard. Enter or = evaluates, Backspace deletes a digit and Esc clears.
- In Scientific mode, a function key such as sin, √ or x! applies to the whole expression typed so far and shows the result straight away.
- In Programming mode, choose HEX, DEC, OCT or BIN first. Switching base converts the current value; the A to F keys only work in HEX.
- Click any line in the History panel to bring that expression and result back into the display.
Worked examples
Floating point noise is rounded away
Input
0.1 + 0.2 =
Output
0.3
The raw double is 0.30000000000000004. Showing 14 significant digits removes the binary rounding artefact while keeping genuinely small values such as 1e-12 intact.
Radians, not degrees
Input
π ÷ 2, then sin
Output
1
π ÷ 2 radians is 90 degrees, so the sine is exactly 1. Typing 90 and pressing sin would give 0.89399666360056, the sine of 90 radians.
Masking a byte in HEX
Input
HEX mode: FF AND 0F =
Output
F (DEC 15, BIN 1111)
AND keeps only the bits set in both operands. 0F is the classic low-nibble mask, so the high four bits of FF are cleared.
Background and insight
Most calculators, this one included, store numbers as IEEE 754 double-precision floats: 53 bits of binary mantissa, roughly 15 to 17 significant decimal digits. Decimal fractions like 0.1 have no exact binary form, so tiny errors appear in the 16th or 17th digit. Rounding the display to 14 digits hides that noise without hiding real results; 1 ÷ 10^12 still shows as 1e-12 rather than being flattened to zero.
Trigonometric functions take radians, which is what mathjs, JavaScript's Math.sin and nearly every programming language use. sin(30) is therefore -0.98803162409286, not 0.5. To work in degrees, multiply by π/180 first: sin(30 × π ÷ 180) = 0.5. The log key is base 10 and ln is the natural log, matching the labels on a desk calculator.
Programmer mode follows the convention of the Windows and macOS programmer calculators: ^ means XOR rather than power, and division truncates toward zero. Operands are read in the active base, so in HEX mode FF AND 0F is 255 & 15 and the answer shows as F, with the HEX, DEC, OCT and BIN readouts updated underneath.
Common use cases
Quick engineering maths
Square roots, powers, logs and factorials without opening a spreadsheet or a Python REPL.
Bit masks and flags
Check what a permission bitmask or register value looks like in binary, or what 1 << 12 equals, while reading C or embedded code.
Checking a percentage
Turn 15 % into 0.15 and multiply it into a price or a ratio without doing the division in your head.
Comparing against code
Confirm what a JavaScript or Python expression should return, including operator precedence and right-associative powers.
Tips and limitations
- The % key divides the number before it by 100, so 200 + 10 % = 200.1. Desk calculators that show 220 apply a different "add a percentage" rule; type 200 × 1.1 for that.
- Function keys wrap everything typed so far. To take the square root of only part of an expression, evaluate that part first with =, then press √.
- Programmer mode works on integers. 7 ÷ 2 gives 3, and entering a digit that does not exist in the active base (9 in BIN, for example) shows Error.
- Factorial accepts non-integers through the gamma function, so 0.5! is 0.88622692545276 (half of √π). Most handheld calculators reject that input.
- Memory and history reset when you reload the page. Copy anything you need to keep.
Sources and further reading
- IEEE 754-2019: Standard for Floating-Point Arithmetic, IEEE Standards Association. The double-precision format the calculator uses
- What every computer scientist should know about floating-point arithmetic, ACM Computing Surveys. David Goldberg, 1991
- Floating-Point Arithmetic: Issues and Limitations, Python Software Foundation. Why 0.1 has no exact binary form
- math.js sin() reference, mathjs. Trigonometric functions take radians
Frequently asked questions
Why does this calculator show 0.3 for 0.1 + 0.2?
Because results are rounded to 14 significant digits before display. The underlying double is 0.30000000000000004, a binary rounding artefact that every IEEE 754 system produces. Rounding the display hides that noise while still showing very small genuine results such as 1e-12.
Does the scientific calculator use degrees or radians?
It uses radians, like mathjs and JavaScript's Math functions. sin(30) returns -0.98803162409286, the sine of 30 radians. To work in degrees, multiply the angle by π ÷ 180 before pressing sin, cos or tan; inverse functions return radians too.
Is log base 10 or the natural log here?
log is base 10 and ln is the natural logarithm, so log(1000) is 3 and ln(e) is 1. That matches desk calculators. Note that in mathjs and most programming languages a bare log() is the natural log, which is a common source of confusion when you copy formulas into code.
How does the % key work on this calculator?
It divides the number immediately before it by 100. 50 % gives 0.5 and 200 + 10 % gives 200.1. Some desk calculators instead treat "+ 10 %" as "add ten percent of the running total", which would give 220. For that result, multiply by 1.1.
What does ^ mean in programming mode?
In Programming mode ^ is bitwise XOR, the same as in C, Java and JavaScript. In Scientific mode the ^ and x^y keys mean exponentiation. 12 ^ 10 is 6 in Programming mode because only the bits that differ between 1100 and 1010 are set.
Can I type hexadecimal numbers into the calculator?
Yes, after selecting HEX. The A to F keys become active and every operand is read as hexadecimal, so FF AND 0F returns F. Switching to DEC, OCT or BIN converts the value on screen, and the four readouts below the display always show the same value in every base.
Is it safe to paste expressions into this calculator?
Expressions are parsed by mathjs, which only understands maths syntax, rather than being passed to JavaScript eval or Function. Programmer-mode input is also checked against a whitelist of digits and operators. Nothing you type leaves your browser.
Is there an in-depth guide to the Scientific Calculator?
Yes. “Why 0.1 + 0.2 Is Not 0.3: Calculator Precision, Precedence and Radians” covers the background, how it works, common pitfalls and worked examples. Read the full guide.
Related Tools You May Like
Free, in-browser tools that pair well with this one.