2. 65
Denary to Binary
Start by writing out the place values.
1248163264128
Then write 1s underneath the place values that add up to the
denary number.
0 1 0 0 0 0 0 1
3. 64 16 1+ + = 81
Binary to Denary
0 1 0 1 0 0 0 1
Start by writing the place values above each bit.
1248163264128
Then write out the place values of the 1s.
Finally add the numbers together.
4. Binary Addition
The process of performing addition in binary is very similar to
addition in denary.
1 1 1 1
0 1 1 0 1
0 0 1 1 1 +
1 0 1 0 0
Rules:
0 + 0 = 0
0 + 1 = 1
1 + 1 = 0 carry 1
1 + 1 + 1 = 1 carry 1
0 1 1 0 0
1 0 1 1 1 +
1 1 1 0 0
1 0 1 0 1 +
5. Overflow
When there isn’t enough room for a result, this is called an
overflow and it produces an overflow error.
1 1 1 1
1 1 1 0 1
1 1 0 1 1 1 +
1 1 0 1 0 0
No room for a carry, so it is lost and we get the wrong answer.
Humans can easily work around this, but it isn’t so easy for a
computer.
6. Binary Subtraction
The process of performing subtraction in binary is very similar
to subtraction in denary.
1 1 0 0
0 1 0 0 -
1 0 0 0
Rule:
0 - 1 won’t go so borrow 10 (2) from the column to the left. 2 - 1 = 1.
10 10
1 1 0 1
0 1 1 1 -
0 1 1 0
1 1 1 0
0 1 0 1 -
7. Sign and Magnitude
This is the simplest method of representing negative numbers
in binary. The most significant bit is the ‘sign bit’.
Sign bit 128 64 32 16 8 4 2 1
0 0 0 0 1 1 0 1 1 +27
1 0 0 0 1 1 0 1 1 -27
1 = minus 0 = plus
8. The Problem with Sign and Magnitude
The problem with sign and magnitude is that addition doesn’t
always work.
0 0 0 0 0 1 1 1 (+7)
1 0 0 0 0 1 0 1 (-5) +
1 0 0 0 1 1 0 0 (-12)
9. Two’s Complement
Two’s complement is an alternative method of representing
negative numbers. This method works with binary addition.
The most significant bit is a minus number.
-128 64 32 16 8 4 2 1
1 0 0 0 1 1 0 1
-128 + 8 + 4 + 1 = -115
10. Floating Point Numbers
In binary floating point numbers are split into two parts; the
Mantissa and the Exponent.
Mantissa Exponent
0111 1000 0000 0011
0 . 1 1 1 1 0 0 0
The mantissa contains the actual number and the exponent
defines the position of the binary point.
11. Floating Point Numbers
The numbers to the right of the binary point define the
fraction.
0 1 1 1 . 1 0 0 0
In denary the number above is:
7 ½
1/2 1/4 1/8 1/16
8/16 4/16 2/16 1/16
12. Hexadecimal
Programmers often use hexadecimal numbers as a shorthand
for binary to save time. Hexadecimal (hex) numbers are based
on the number 16. Each column has a value 16 times that of
the one on its right.
place value 256 16 1
There are 16 different values available in hex:
Letters are used for values 10-15 to ensure that only single
digits are used.
0 1 2 3 4 5 6 7 8 9 A B C D E F
13. Hexadecimal to Binary
Converting between hexadecimal and binary is particularly easy. You
just take each character and convert it into the equivalent binary
number.
Hex D B
Denary 13 11
Binary 1 1 0 1 1 0 1 1
In this example we will convert DB hex to binary.
14. Binary to Hexadecimal
You convert between binary and hexadecimal by doing the reverse.
You just take each group of four binary digits, starting from the
right and convert it into the equivalent hex number.
Binary 1 1 1 1 0 0 1 1
Hex F 3
In this example we will convert 11110011 to hexadecimal: