Two's complement

From Just Solve the File Format Problem
(Difference between revisions)
Jump to: navigation, search
(Created page with "{{FormatInfo |formattype=electronic |subcat=Binary Data }} '''Two's complement''' is the most common way to represent a signed integer using a fixed number of bits. The high ...")

Revision as of 00:29, 18 April 2013

File Format
Name Two's complement
Ontology

Two's complement is the most common way to represent a signed integer using a fixed number of bits.

The high bit is used as the sign bit. If the sign bit is 1, the number is negative. If it is 0, the number is positive or zero. Positive numbers use the standard base-2 representation.

To convert a number N to −N, invert all the bits, then add 1, discarding any carry. This works for any number except the maximally negative number, which has no positive equivalent.

The term two's complement also means the operation described above.

Resources

Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox