Home Tools Blog About

Encode Negative Binary

In short

Encode negative numbers in binary using two's complement, one's complement, or sign-magnitude, with the bit width you choose. Free and in-browser.

  • Runs in your browser
  • Nothing uploaded
  • Free, no sign-up

Convert negative decimal integers to two's complement binary at 8, 16, 32, 64, or any custom bit width up to 256. Optional step-by-step view shows the magnitude → invert → +1 derivation. BigInt under the hood, so arbitrary widths work.

🛡
100% PrivateNo server uploads, ever
InstantRuns in your browser
💧
No WatermarksClean output, always
🆓
Free ForeverNo accounts, no limits

How to Use Encode Negative Binary

Encode Negative Binary · free online tool · All Tools Verse
Encode Negative Binary. Free online tool that runs in your browser.
  1. Enter negative integers (one per line) in the input box.
  2. Pick a bit width - 8, 16, 32, 64, or Custom (4-256). The lower bound on representable values is −2 to the (N−1); going below it triggers a per-line range error.
  3. Optionally enable "Show encoding steps" to display the derivation: take the absolute value's binary, invert every bit, add 1.
  4. Click Convert or press Ctrl/Cmd + Enter. The output box shows one row per input with the sign bit highlighted on the left.
  5. Copy or download as twos-complement.txt.

Frequently Asked Questions

Does this tool handle positive numbers too?

No. The tool is named “Negative Binary Encoder” and is restricted to strictly negative integers. An older version of this FAQ claimed positive numbers worked – that was incorrect; the code throws on zero or positive input. If you want to encode positive integers as binary, use a regular decimal-to-binary tool; if you want to see how positive numbers fit into the same two’s complement bit pattern, just take the ordinary binary of the positive value and pad to the bit width.

What is two’s complement?

Two’s complement is the dominant way to represent negative integers in binary on modern CPUs. For an N-bit field, the value −x is encoded as the N-bit pattern that, when added to x (mod 2 to the N), gives zero. Practically: take the binary of |x|, invert every bit, then add 1. Examples at 8 bits: −1 → 11111111, −128 → 10000000.

Why does the sign bit matter?

In two’s complement, the leftmost (most-significant) bit doubles as a sign indicator: 1 means the value is negative, 0 means non-negative. This tool highlights the sign bit in indigo so you can quickly verify the sign of a freshly computed pattern. Note that the sign bit isn’t a “separate” bit added on top – it’s just the top bit of the N-bit field, and it carries arithmetic weight equal to −2 to the (N−1).

What’s the representable range at each bit width?

For N bits, two’s complement covers [−2^(N−1), 2^(N−1) − 1]. So 8-bit covers −128…127; 16-bit covers −32,768…32,767; 32-bit covers about ±2.1 × 10⁹; 64-bit covers about ±9.2 × 10¹⁸. The tool rejects any input below the lower bound for the chosen width – try a wider width or scale your problem.

What does the “show steps” toggle do?

When on, each row expands to show the three classical steps: (1) the bit pattern of the absolute value, (2) that pattern with every bit inverted (the “one’s complement”), and (3) adding 1 to get the two’s complement. Helpful for teaching, debugging, and sanity-checking your hand calculations.

Why use BigInt instead of plain Number?

JavaScript Numbers are 64-bit floats with only 53 bits of integer precision. For 53-bit-and-larger widths (e.g. 64-bit signed integers like the minimum −2⁶³), Number would silently lose precision. BigInt is unbounded, so 64-bit values are exact and arbitrary widths up to 256 bits work without precision loss.

Is anything sent to a server?

No. The page loads three static files (HTML, CSS, JS) and then runs entirely in your browser. You can disconnect from the internet after the page loads. No analytics, no tracking, no cookies.

Is this tool free?

Yes – free, unlimited, no signup, no watermark. Use the output in any context. Attribution to is appreciated but not required.

Keep going

Related Tools

All Binary tools →

Decode Negative Binary

Decode Negative Binary online, free and private. Runs in your browser, no upload, instant…

Calculate Bitwise AND of Binary Values

Calculate Binary Values Online Free - Fast and accurate binary computations for developers, students,…

Binary to Decimal Converter

Convert extremely large machine binary strings natively into format decimal bounds infinitely fast offline…

Calculate Binary Addition

Calculate Binary Addition numbers with carry visualization and multi-format output. Free, offline, client-side, instant…

Binary to Gray Code Converter

Convert binary to Gray code (BRGC) - XOR algorithm, bit-width preserved, step-by-step display, BigInt.…

Binary to Image Converter

Render binary as a pixel image - multiple color schemes, pixel scaling, PNG export,…

Binary to IP Converter

Convert 32-bit binary to IPv4 or 128-bit binary to IPv6 - with classification, canonical…

Binary to IPv6 Converter

Convert 128-bit binary to IPv6 addresses - RFC 5952 canonical form, special-range detection. Free,…

Binary to Negabinary Converter

Convert binary to negabinary (base -2) - handles signed input, BigInt precision, no sign…

Convert Binary to Octal

Convert binary to octal (base 8) - 3-bit grouping, prefix options, BigInt precision, batch…

Binary to String Converter

Decode binary to text - UTF-8, Latin-1, or 7-bit ASCII, auto-detect format, handle emoji.…

Convert Decimal to Binary

Convert decimal numbers to binary instantly, one value or a whole list at a…

Share

Embed this tool

Add this free tool to your website. Copy and paste the code: