Data Binary Arithmetic
Binary Addition The process of performing addition in binary is very similar to addition in denary. 1 + 1 + 1 + Rules: 0 - 0 + 1 = 1 1 + 1 = 0 carry 1 1 + 1 + 1 = 1 carry 1 Question: What is 1011 + 1000? Complete tasks 4.1 and 4.2.
Overflow When there isn’t enough room for a result, this is called an overflow and it produces an overflow error. 1 + 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.
Binary Subtraction The process of performing subtraction in binary is very similar to subtraction in denary. 1 - 10 1 - 1 - Rule: 0 - 1 won’t go so borrow 10 (2) from the column to the left. 2 - 1 = 1. Question: What is 1011 - 1000? Complete tasks 4.3 and 4.4.
1 = minus 0 = plus Sign and Magnitude This is the simplest method of representing negative numbers in binary. The most significant bit is the ‘sign bit’. 1 = minus 0 = plus Sign bit 128 64 32 16 8 4 2 1 +27 -27 Question: Convert this sign and magnitude binary number to denary: 1111 Complete tasks 4.5 and 4.6.
The Problem with Sign and Magnitude The problem with sign and magnitude is that addition doesn’t always work. 1 (+7) (-5) + (-12)
-128 + 8 + 4 + 1 = -115 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 -128 + 8 + 4 + 1 = -115 Question: Convert this sign and magnitude binary number to denary: 1101 Complete tasks 4.7 and 4.8.
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.
Floating Point Numbers The numbers to the right of the binary point define the fraction. 0 1 1 1 . 1 0 0 0 1/2 1/4 1/8 1/16 8/16 4/16 2/16 1/16 In denary the number above is: 7 ½ Complete task 4.9.