YourTools.
简体中文
Back to the catalog
Tools

Sign-magnitude, ones’ and two’s complement

Sign-magnitude, ones’ complement and two’s complement of decimal integers, one per line, at 8, 16, 32 or 64 bits.

Process locally

Files stay in this browser session. Closing or clearing releases them.

Add text

Type or paste the text to process

Adjust settings

Optional: Bit width

Sign-magnitude, ones’ and two’s complement

Run

Processes in this browser; cancel at any time

Add text first

About this tool

Work out the sign-magnitude, ones’ complement and two’s complement forms of decimal integers at 8, 16, 32 or 64 bits. It helps with computer architecture classes and homework, or when you want to see how a negative number is stored in memory. Put one number per line to get a whole list in one run.

Bits are grouped in fours, and the two’s complement is also shown in hex: at 8 bits, -5 is 1000 0101 in sign-magnitude, 1111 1010 in ones’ complement and 1111 1011 (FB) in two’s complement. Only decimal integers are accepted, and the work is done in your browser.

How to use it

  1. Under “Add text”, type one decimal integer per line, or select Use example.
  2. Choose the “Bit width”: “8-bit”, “16-bit”, “32-bit” or “64-bit”. The default is 8-bit.
  3. Select Run.
  4. Check each number’s sign-magnitude, ones’ complement, two’s complement and hex in the preview, then download the results as a text file.

Formats and limits

Input
Text
Output
Plain text
Size limit
1 MB
Settings
Bit width (8-bit, 16-bit, 32-bit, 64-bit)
Privacy
Files stay in the current browser session. No file bytes are uploaded.
Price
Free, no sign-up

Common questions

Why do sign-magnitude and ones’ complement show n/a for -128?

At 8 bits, sign-magnitude and ones’ complement only cover -127 to 127, so -128 exists only in two’s complement, as 1000 0000. The same goes for the smallest negative number at every width.

Are the three forms different for positive numbers?

No. Positive numbers and zero look the same in all three. For a negative number, ones’ complement flips every bit of the sign-magnitude form except the sign bit, and two’s complement adds 1 to that.

What if a number is out of range?

Each width has a limited range: -128 to 127 at 8 bits, -32768 to 32767 at 16 bits and -2147483648 to 2147483647 at 32 bits. A number outside the range stops the run with an error, so pick a wider bit width.

Can I enter hex numbers or decimals?

No, only decimal integers, with an optional sign; spaces and underscores inside a number are ignored. To convert between hex, binary and other bases, use the “Number base converter” tool.

Is 64-bit exact?

Yes. The tool calculates with arbitrary-precision integers, so every value from -9223372036854775808 to 9223372036854775807 comes out exactly.