How To Convert Negative Numbers To Binary

You have almost certainly heard of negative numbers. If you've had even a little exposure to the world of computer science and computer programming, the concept of binary numbers is not entirely foreign. But unless you have explored the programming world personally, you have probably never worked substantively with binary numbers.

Advertisement

Because computers cannot "think" or "decide" on their own but can follow ordered instructions with unfailing accuracy, mathematicians long ago came up with a way for computers (or sufficiently patient humans) to do addition, subtraction and other mathematical operations using only the digits 0 and 1.

But is there a way to combine these two ideas to produce negative numbers? Is it as simple as telling a machine to stick a small horizontal bar in front of an existing number a la pen and paper, or does the "bits and bytes" factor make things more involved?

What Are Binary Numbers?

Computers have an enormous amount of processing power, and even an old clunker can perform computations at a rate that would seem incomprehensible to even the most arithmetically gifted human being. But they are not brains, and the only way to get them to handle complex information is to relegate everything possible to one of two states, e.g., ON or OFF.

Advertisement

In "computer-ese," a single 0 or 1 is referred to as a bit. Groups of these include the nybble (4 bits), the well-known byte (8), the word ( 1) and the long word (32).

The decimal numbers you typically see, like 492 and 35, are "base-10," because they include 10 progressive symbols (the digits 0 through 9) that "roll over" to the next place leftward — the next "power of 10." Binary numbers, instead, include only two symbols (the digits 0 and 1) and are "base-2." Each leftward move from the end of the number is an increasing power of two: The end digits represent 1, the next 2, then 4, 8, 16 and so on.

A decimal number is any number in the base-10 system, not necessarily a number that includes a decimal point.

Advertisement

Examples of Binary Numbers

The binary "nybble" 0101 has 1's in the 1 place and the 4 place, and 0's in the 2 and the 8 place. Thus its decimal equivalent is 1 + 4 = 5.

Similarly, the byte 1001 1100 is equivalent to 128 + 16 + 8 + 4 (28 + 25 + 24 + 23) = 156.

Advertisement

The complement of a binary number is just the number with its digits "switched." For example, the complement of 1001 1100 = 0110 0011.

Converting Negative Numbers to Binary

How you convert a negative decimal number to a binary number is probably quite unlike other numerical conversions you have performed because your mind, for all its comparative sloth, is a lot more flexible in most ways than any CPU. However, it is a straightforward process.

Advertisement

The conversion is done using a two's complement binary, which requires the programmer to instruct the computer to interpret any binary number starting with 1 as negative. The program then constructs the corresponding positive number in binary, takes its complement and adds one.

For example, given the number −47, the computer would create the binary number for +47:

0001 1111

The complement of this is:

1110 0000

Adding one to this gives:

1110 0001

Note that the computer has "signed" these numbers to treat a leading 1 as negative and process the results differently than simply adding up the powers of 2 occupied by the symbol 1.

Cite This Article

MLA

Beck, Kevin. "How To Convert Negative Numbers To Binary" sciencing.com, https://www.sciencing.com/convert-negative-numbers-binary-5124016/. 1 March 2020.

APA

Beck, Kevin. (2020, March 1). How To Convert Negative Numbers To Binary. sciencing.com. Retrieved from https://www.sciencing.com/convert-negative-numbers-binary-5124016/

Chicago

Beck, Kevin. How To Convert Negative Numbers To Binary last modified August 30, 2022. https://www.sciencing.com/convert-negative-numbers-binary-5124016/

Recommended

Advertisement