Two's Complement / Signed Integer Calculator
Convert between signed decimal and two's-complement binary at any width (4/8/16/32/64-bit or custom up to 256-bit). Step-by-step negation (invert → +1), one's-complement and sign-magnitude side-by-side, clickable bit grid with MSB sign bit highlighted, hex/octal views, range & overflow detection, and sign-extension / truncation visualization. BigInt-correct, fully client-side.
About Two's Complement / Signed Integer Calculator
Convert between signed decimal and two's-complement binary at any width (4/8/16/32/64-bit or custom up to 256-bit). Step-by-step negation (invert → +1), one's-complement and sign-magnitude side-by-side, clickable bit grid with MSB sign bit highlighted, hex/octal views, range & overflow detection, and sign-extension / truncation visualization. BigInt-correct, fully client-side. Everything runs locally in your browser — your data never leaves your device.
How to use
- Enter your input in the tool above.
- Adjust any options to your preference.
- Use the Copy or Download buttons to save the result.
- Everything happens locally — your data never leaves your browser.
FAQ
What is two's complement and how is it computed?
Two's complement is the standard way signed integers are represented in modern CPUs. For an N-bit value, the most-significant bit (MSB) is the sign bit (0 = non-negative, 1 = negative). To negate a value you invert every bit (one's complement) and then add 1 — this is the famous 'invert and add 1' rule. The tool shows this step-by-step so you can verify e.g. that −5 in 8-bit becomes 11111011.
What is the valid range for each bit width?
For N-bit two's complement, the representable range is −2^(N−1) … 2^(N−1) − 1. So 8-bit is −128 … 127, 16-bit is −32768 … 32767, 32-bit is −2147483648 … 2147483647, and 64-bit is −9223372036854775808 … 9223372036854775807. The tool always displays the current range and flags any input that falls outside it as an overflow.
What is the difference between two's complement, one's complement, and sign-magnitude?
Two's complement negates by inverting all bits and adding 1 (no ±0 ambiguity, single zero). One's complement negates by inverting all bits only (so +0 = 0000 and −0 = 1111 both exist). Sign-magnitude uses the MSB as a pure sign flag and the remaining bits as a magnitude (so −5 = 1_0000101 in 8-bit, with the same ±0 ambiguity). The tool shows all three representations side-by-side so you can compare them.
How does sign-extension work when changing bit width?
When you widen a two's-complement value, the new high-order bits are filled with copies of the original sign bit. So 8-bit 0xFB (−5) sign-extended to 16-bit becomes 0xFFFB. When you narrow, the high bits are simply dropped — if any of those dropped bits differ from the new sign bit, the value changes (overflow). The tool visualizes both directions whenever you change the width.
What extra features does this tool have versus other two's-complement calculators?
(1) Any width from 4 to 256 bits (preset 4/8/16/32/64 or custom). (2) All three representations — two's, one's, sign-magnitude — side-by-side. (3) Step-by-step negation panel showing invert → +1. (4) Clickable bit grid: click any bit to toggle and watch the decimal value update live. (5) MSB sign bit visually highlighted. (6) Per-bit weight tooltips (2^k). (7) Hex / octal / decimal / binary views simultaneously. (8) Live range display + overflow flag. (9) Sign-extension & truncation visualizer when width changes. (10) Handles the most-negative value (−2^(N−1)) which has no positive counterpart. (11) History (localStorage, last 20). (12) Shareable URL with full state round-trip. 100% client-side and offline — your values never leave the device.
Related tools
.bashrc / .zshrc Alias & Config Manager
Build shell aliases, functions, exports, and PATH edits in a visual editor, then export a clean, commented .aliases file sourced from both .bashrc and .zshrc — with shadowing detection against shell builtins and common CLI tools, function suggestions when args are needed, starter packs (git, docker, kubectl, navigation, safety, ls, dev, devops, data science), import of existing rc files, dedupe, history (localStorage), and shareable URL. 100% client-side.
Add / Subtract Date Calculator
Add or subtract years, months, weeks, days, hours, minutes and seconds from a starting date/time. Calendar-day or business-day mode with custom weekend + holiday list. Month-end policy toggle (clamp to last day vs overflow). Repeat/series mode (e.g. every 2 weeks x 10) with CSV export. Shareable URL. 100% client-side.
Age Calculator
Calculate exact age from a birth date in calendar years/months/days (no negative-day bugs) plus totals in months/weeks/days/hours/minutes/seconds. Next-birthday countdown with weekday. Feb-29 birthday policy toggle. Milestones (1,000 days, 10,000 days, 1 billion seconds). Zodiac sign + Chinese zodiac. Age gap comparison. Shareable URL. 100% client-side.