## Introduction: Convert Negative Numbers to Binary

**Introduction**

The binary number system plays a central role in how information is stored and calculated on computers. Knowing how the binary system works, can help us understand how computers function, translate input and display results/outputs.

This instructable is about negative binary numbers. It will teach you how to convert negative numbers to binary numbers. Instructions for adding in binary have also been included in this instructable.

__Supplies:__

· Pencil

· Paper

· Calculator (recommended)

** Time:** 15 – 20 minutes

## Step 1: Divide Until You Reach Zero

__Example__

Take the number, ignore the negative sign, and divide the number by 2 and write down the remainder to the right as shown in the picture. (In the picture 'R' stands for the remainder.) Even if the remainder is 0, write it down to the right. Now, keep dividing each quotient by 2 until zero is the quotient and keep writing down the remainder to the right. It is better to continue this division downward by writing down each quotient under the previous quotient as shown in picture.

If you have trouble dividing the number use a calculator. In the calculator, when you divide a number by 2, you will either get a whole number(ex: 22) or get a number ending in .5(ex: 22.5). If the quotient is a whole number it means that the remainder is 0 and if the quotient ends in .5 it means that the remainder is 1. As you are dividing, make sure all the remainders are either 1 or 0. When you are finished check to make sure that the number of times you divide equals the number of remainders you have to the right. In the example, notice that the number has been divided 9 times and there are 9 remainders written to the right.

## Step 2: Derive Result

__Example__

Write down the remainders bottom to top linearly to get a sequence of 1s and 0s (binary sequence), as shown in the picture. Make sure that the length of the binary sequence is equal to the number of remainders you have written to the right of your division.

Now, starting at the end of the binary sequence draw a long line every 4 numbers. Refer to the picture if you have any confusion.

## Step 3: Extend Binary Sequence

The size of the binary sequence can either be a double word, word, or a byte, which are 32, 16, and 8 bits respectively. 32, 16 or 8 are the number of binary numbers( 1s or 0s), you will have in your final answer. Most times if the problem asks us to find the double word/word-length/ byte-length binary representation of a number we extend the answer to their size with 0s.

Byte = 8 bits = 8 numbers in binary sequence

Word = 16 bits = 16 numbers in binary sequence

Double Word = 32 bits = 32 numbers in binary sequence

Few examples on extending:

- If our binary sequence ends up being 111 1000, and we are told to find the byte-length binary representation we add an extra zero to the beginning, so that the final binary sequence is: 0111 1000. We add one zero to the front because our binary sequence had only 7 numbers and a byte requires 8 numbers and 8 - 7 = 1.

- If our binary sequence ends up being 01 0111 1000, and we are told to find the word-length binary representation we add six zeros to the beginning, so that the final binary sequence is: 0000 0001 0111 1000. We add six zeros to the front because our binary sequence had only 10 numbers and a byte requires 16 numbers and 16 - 10 = 6.

__Example__

In our example, the binary sequence we have is 1 0100 1000, and we are told to find the word-length binary representation. There are 9 numbers in this binary sequence and we need there to be 16 numbers in the sequence. So, we add seven zeros to the beginning of the binary sequence (16 - 9 = 7).

## Step 4: 2’s Complement Representation

2's Complement notation is how every computer represents negative integers. To get the two's complement notation of a negative integer, you write out the number in binary, invert the digits, and then add one.

__Example__

Draw a line under the binary sequence from previous step and flip each bit(under each 1 write down a 0 and under each 0 write down a 1). The new “flipped” binary sequence should be the same length as the previous binary sequence.

## Step 5: Add One

There is one important rule to binary addition. If we are adding a 1 and a 1 it is equal to 10, not 2. So when we add 1 and 1, we place 0 in the answer box and carry the 1 (add as if you are adding 10 to normal numbers).

__Example__

See the example in the picture, if you have any confusion on how to add.

## Step 6: Final Answer Format

There are 3 ways to represent numbers in computer science: binary, hexadecimal and decimal. Decimal is the way we represent numbers in every day life and has a base 10. Hexadecimal, like binary is another way we represent numbers and has a base 16. Binary has a base of 2.

Decimal ---> Base 10

Hexadecimal --> Base 16

Binary --> Base 2

__Example__

Group the binary sequence into groups of 4 leaving a space between each group, as shown in the picture. To indicate our answer is in binary (binary numbers are base 2), we must include a 2 at the bottom right corner of the sequence.

## Step 7: Practice!

For more practice, here are some links:

http://www.free-test-online.com/binary/two_complem...

https://courses.cs.vt.edu/~csonline/NumberSystems/...

To check if you are getting the right answers, here is an online calculator:

## 3 Discussions

Binary code for -3

This part of electronics is the mos boring one idk why i just finde it that way.We have learned to do hex to binary and decimal to hex etc.Its just boring.

Interesting. I always wondered how to do that.