Home / Developer Tools / Two's Complement Calculator
Developer Tools

Two's Complement Calculator

Two’s complement defines signed interpretation; it does not by itself define byte order.

—Two's complement uses an explicit signed bit width.

Range, hex & overflow audit

Expose the signed range for the selected width and verify the same bit pattern as signed, unsigned and hexadecimal.

Bit-width evidence
Use the tool above, then refresh this audit.
Audit uses the visible inputs plus the assumptions shown here.

Practical guide and verification

Bit width is part of the value

Two’s-complement interpretation depends on a fixed bit width. The same hex or binary pattern can represent a different signed number when interpreted with a different number of bits.

Positive and negative ranges

An n-bit signed two’s-complement integer ranges from −2^(n−1) through 2^(n−1)−1. The asymmetry means the most negative value has no positive counterpart in the same width.

Common mistake

Do not invert bits and add one without first fixing the width. Leading zeros or ones are significant when you are representing a finite-width signed integer.

Bit-pattern resize, sign-extension & overflow audit

Keep the primary decimal/binary conversion, then treat a two’s-complement value as a fixed-width machine bit pattern. Resize it by sign extension, zero extension or truncation and inspect signed/unsigned interpretations, hexadecimal form, discarded bits and round-trip safety.

—Source signed value
—Source unsigned value
—Result bit pattern
—Result signed value
—Overflow / information loss
StageWidthBinaryHexSignedUnsigned
Ready.

Widths are limited to 64 bits and are evaluated with BigInt so the browser does not lose integer precision. Truncation can preserve low-order bits while changing the signed numeric value.

Representation is context

A hexadecimal or binary string does not automatically tell you whether a value is signed, how wide it is, whether bytes are little endian, or whether the bits represent an integer or floating-point value.

Search by task, tool name, or category. Press Esc to close.
Start typing to find a tool.