Positional Number Systems- Each digit position has an associated weight- The value of the number i a weighted h l f h b is i h d sum of the digits- Th di it i position I h weight ri , The digit in iti has i ht Where r is the radix (base) ( )
OOctal and Hexadecimal Numbers- Radix 8 and 16- Useful for representing multi-bit numbers p g-Conversion from binary is doneby separating the bits into groups ofthree or four (R-L) and replace each groupwith the corresponding octal or hexadecimalnumber
- If the number contains digits to the right of the binary point, we group the part after the binary point(L-R)- To convert from Octal and Hexadecimal, we replace each digit with the corresponding 3 or 4 bits string string.- Conversion from Decimal to Binary,Octal & y, Hexadecimal is achieved by dividing by the radix.
FractionsBinary to decimal10.1011 >10 1011 => 1 x 2-4 = 0.0625 1 x 2-3 = 0.125 0 x 2-22 = 0.0 0 0 1 x 2-1 = 0.5 0 x 20 = 0.0 1 x 21 = 2.0 2 0 2.6875
Hexadecimal Addition (& Subtraction)A C 5 A 9E D 6 9 4 D
Representation of negative numbers ep ese tat o o egat ve u be s- Singed-magnitude system: the number consists Singed magnitude of magnitude and symbol. The MSB is for the sign 0 means positive &1 means negative- There are two representation for 0 1000 ( 0) & 0, (-0) 0000 (+0).- For n-bit integer the range is –(2n-1 – 1) to +(2n-1-1) +18 = 00010010 -18 = 10010010 18
- One complement : The MSB is for the sign.- Boolean complement all bits to negate +18 = 00010010 -18 = 11101101- Two representations of zero: 0000 (+0) 1111 (-0)- The range is –(2n-1 – 1) to +(2n-1-1). (2n (2n 1).
- Two’s complement: MSB is for the sign sign.- The range is –(2n-1) to (2n-1-1) (2 -1).- 3 = 00000011 Boolean complement gives 11111100 B l l i Add 1 to LSB +1 11111101
- Only one representation for 0 0. 0 = 00000000 Bitwise not 11111111 Add 1 t LSB to +1 Result 1 00000000Overflow is ignored, so:-0=0
-T ’ Two’s C Complement Additi l t AdditionOverflow: An addition overflows if thesigns of the addends are the same and thesign of the sum i diff i f h is different f fromthe addends’ sign addends sign.
The Byte Nibble, and Word Byte, Nibble• 1 byte = 8 bits• 1 nibble = 4 bits• 1 word = size depends on d t pathway d i d d data th size. – Word size in a simple system may be one byte (8 bits) – Word size in a PC is eight bytes (64 bits)
-Codes are group of special symbols used t C d f i l b l d torepresent numbers, letters or words.1- Binary codes for decimal numbers (BCD) y ( )- Binary Coded Decimal (BCD) is another way to present decimal numbers in binary form.- BCD is widely used and combines features of both decimal and binary systems.
- Each digit of a decimal is represented by its four bit four-bit binary equivalent (1 to 9)- To represent the decimal number 10 we need n mber e eight bits (0001 0000)
• To convert the number 87410 to BCD 8 7 4 (decimal) 1000 0111 0100 (BCD)• Each digit always uses four bits. ac d g t a ways ou b ts.• The BCD value can never be greater than 9• Reverse the process to convert BCD to decimal.
• BCD i not a number system. is t b t• BCD is a decimal number with each digit encoded to its binary equivalent. equivalent• A BCD number is not the same as a straight binary number. number• The primary advantage of BCD is the relative ease of converting to and from decimal.
22- American Standard Code for Information Interchange (ASCII)- It is a seven bit code. It has 27 possible codegroups.- Represents characters and functions found ona computer keyboard.- Examples of use are: to transfer informationbetween computers, between computers andprinters, and f i i d for internal storage. l
3-3 Gray codeTwo successive values differ in only one bit
• 4- Codes for detecting and correcting errors• Error means corruption of data data.• - Parity Bit• - Hamming C d i Code
Parity bit: It is an extra bit that is attached to a code group that is being transferred from onelocation to another. It is made either 0or 1 Depending on the number of 1 that 1. di h b f 1s hare contained in the code group.Even parity:The value of the parity bit is chosen so thatthe total number of 1s including the parity 1s,bit, is an even number; 1 1000011
Odd parity:The value of the parity bit is chosenso th t th t t l number of 1 i l di th that the total b f 1s, including theparity bit, is an odd number; 1 1000001
Assignment (1)1- Indicate whether or not overflow occurswhen adding the following 8-bits 8 bitstwo’s complement numbers 00100110 + 01011010(2.12 d textbok2)2- 2-1.c (textbook1)3- 2-11.c4 2 19.c4- 2-19.c5- 2-24