Title: Some Binary Bits and Pieces
1Some Binary Bits and Pieces
- Terminology
- Each binary digit is called a bit.
- Eight binary digits are called a byte.
- The left most bit is called the most significant
bit (or MSB). - The right most bit is called the least
significant bit (or LSB). - Range is 0 . 2N - 1
2Binary Arithmetic(1)
Rules for binary arithmetic are the same as for
decimal arithmetic. 0 0 1 0 1 0 1 0 42 0 0 0
1 1 1 1 1 31 0 1 0 0 1 0 0 1 73
3Binary Arithmetic(2)
Another example 0 0 0 0 1 0 1 1 11 0 0 0
1 0 1 0 1 21
4Binary Arithmetic(3)
Another example 0 0 0 1 0 1 0 1 - 21 0 0 0
0 1 0 1 1 11
5Examples
6Try This
1 0 0 0 1 1 1 0 1 0 0 0 0 0 1 1 Remember we
are only using 8 bit number representation
7Overflow
Binary numbers often have to be held in a fixed
number of bits. This introduces the problem of
overflow.
8Signed and Unsigned Numbers
The previous section assumes only positive
numbers are represented. Three methods you should
know about for representing negative numbers (all
use the same method for positive numbers) (a)
Sign and Magnitude (b) Diminished Radix
Complement (Ones Complement) (c) Radix
Complement (Twos Complement)
9Twos Complement(1)
Any pattern whose sign bit is 1 represents the
negative ofthe value obtained by replacing each
1 with a 0 and each 0with a 1, and then adding 1
to the final value. So, as with ones complement
except you add an extra one(hence twos
complement!). e.g. 1 0 1 1 0 1 1 1 is a negative
number. Changing 1?0 and 0 ?1 gives Adding 1
gives
10Twos Complement(2)
Range is - (2 N-1) to (2 N -1 - 1) So for 8
bits this is
11Twos Complement(3)
You can perform arithmetic in twos complement
using only addition . So for example to evaluate
41-31 we add 41 and the representation of -31
together.
12Twos Complement(4)
13More Examples (2s complement)
14Error Checking
PARITY is a method for checking for errors Two
types ODD parity and EVEN parity EVEN parity
counts number of occurrences of 1s in the binary
string and then adds an extra bit set to 1 if
there are an even number (else it sets it to
0) ODD parity counts number of occurrences of 1s
in the binary string and then adds an extra bit
set to 1 if there are an odd number (else it sets
it to 0)
15Binary Number Format
parity bit
sign bit
data bits
Now our 8-bit number can store the range of
numbers - 64 through to 63
16Examples
- In decimal what do the following even parity
binary numbers represent?
17Characters and Symbols(1)
ASCII American Standard for Information
Interchange These are represented by 8 bit even
parity code The format of the code is - 7 6 5
4 3 2 1 0
P
ZONE
NUMERIC
This indicates that the zone is 0 7 and the
numeric is 0 15(F)
18Characters and Symbols(2)
- all numerals lie in zone 3
- upper case letters in zones 4 and 5
- lower case in zones 6 and 7
- zones 0 and 1 contain non printing characters
- DEL is the only non printing character in zones 2
to 7
19ASCII TABLE
The following slide shows a condensed version of
the ASCII table The hex value for each of the
codes is the first digit is the top row value and
the second digit is the first column value. For
example N is 4E. Write down the characters for
the following.
Manchester United. (18 characters)
20(No Transcript)
21Examples
- Translate the following into characters
- 49 66 20 79 6F 75 20 63 61 6E 20 64 6F 20 74 68
69 73 20 - 74 68 65 20 65 78 61 6D 20 77 69 6C 6C 20 62 65
20 65 61 73 79 2E