Académique Documents
Professionnel Documents
Culture Documents
Stone Age: knots, some stone marks Roman Empire: more systematic notation I, II, III, IV, V, VI, VII.VIII, IX, X, C=100, D=500, M=1000, L=50 Concept of zero by
Maya- I century, Hindu-V century
Positional-Value System
The value of a digit (digit from Latin word for finger) depends on its position
Positional values 2 1 0 (weights) 10 10 10
-1 -2 -3
10 10 10
5 6 7 . 9 1 4
Decimal point We will write ( 5 6 7. 9 1 4) 10 MSD LSD
1 0 1 1 1 1 . 0 0 1
Binary Representation
The basis of all digital data is binary representation. Binary - means two
1, 0 True, False Hot, Cold On, Off
We must be able to handle more than just values for real world problems
1, 0, 56 True, False, Maybe Hot, Cold, LukeWarm, Cool On, Off, Leaky
Number Systems
To talk about binary data, we must first talk about number systems The decimal number system (base 10) you should be familiar with!
A digit in base 10 ranges from 0 to 9. A digit in base 2 ranges from 0 to 1 (binary number system). A digit in base 2 is also called a bit. A digit in base R can range from 0 to R-1 A digit in Base 16 can range from 0 to 16-1 (0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F). Use letters A-F to represent values 10 to 15. Base 16 is also called Hexadecimal or just Hex.
D di 10i
i 0
p 1
hex
If ALL numbers on a page are the same base (ie, all in base 16 or base 2 or whatever) then no symbols will be used and a statement will be present that will state the base (ie, all numbers on this page are in base 16).
Common Powers
2-3 = 0.125 2-2 = 0.25 2-1 = 0.5 20 = 1 21 = 2 22 = 4 23 = 8 24 = 16 25 =32 26 = 64 27 = 128 28 = 256 29 = 512 210 = 1024 211 = 2048 212 = 4096
210 = 1024 = 1 K 220 = 1048576 = 1 M (1 Megabits) = 1024 K = 210 x 210 230 = 1073741824 = 1 G (1 Gigabits)
8
9 10
1000
1001 1010
10
11 12
8
9 A
11
12 13 14 15
1011
1100 1101 1110 1111
13
14 15 16 17
B
C D E F
Binary to Hex is just the opposite, create groups of 4 bits starting with least significant bits. If last group does not have 4 bits, then pad with zeros for unsigned numbers. % 1010001 = % 0101 0001 = $ 51 Binary to hex conversion
A Trick!
If faced with a large binary number that has to be converted to decimal, we first convert the binary number to HEX, then convert the HEX to decimal. Less work! % 110111110011 = % 1101 1111 0011 = $ D F 3 = 13 x 162 + 15 x 161 + 3x160 = 13 x 256 + 15 x 16 + 3 x 1 = 3328 + 240 + 3 = 3571
Of course, you can also use the binary, hex conversion feature on your calculator. You can use calculators on exam
Binary Codes
One Binary Digit (one bit) can take on values 0, 1. We can represent TWO values: (0 = hot, 1 = cold), (1 = True, 0 = False), (1 = on, 0 = off). Two Binary digits (two bits) can take on values of 00, 01, 10, 11. We can represent FOUR values: (00 = hot, 01 = warm, 10 = cool, 11 = cold). Three Binary digits (three bits) can take on values of 000, 001, 010, 011, 100, 101, 110, 111. We can represent 8 values 000 = Black, 001 = Red, 010 = Pink, 011 = Yellow, 100 = Brown, 101 = Blue, 110 = Green , 111 = White.
Code Conversions
( )2
( )4
( )8
( )16
To convert a binary number to a system which is base-2z, group digits together by z and convert each group separately 100111.1010 ---> ( )16 Converting from binary base hex as an example of base 2Z
. A
Conversion ( ) I
( )10
express number as a power series in I, and add all terms using decimal addition
Converting from base I to decimal
Decimal-to-Radix-r Conversions
Radix-r-to-decimal conversions are easy since we do arithmetic in decimal. However, decimal-to-radix-r conversions using decimal arithmetic is harder. To do the latter conversion, we convert the integer and fractional parts separately and add the results afterwards.
Convert ( ) 10
Integer part:
( )r
Divide the number and all successive quotients by r accumulate the remainders
Fractional part:
Multiply the number and successive fractions by r accumulate the integers
/2 = 3 remainder 1
/2 = 1 remainder 1 /2 = 0 remainder 1 (MSB)
Answer = .01001
.4 * 2 = .8 integer part = 0
.8 * 2 = 1.6 integer part = 1 .6 * 2 = 1.2 integer part = 1, etc.
Most Significant Digit (has weight of 25 or 32). For base 2, also called Most Significant Bit (MSB). Always LEFTMOST digit.
Least Significant Digit (has weight of 20 or 1). For base 2, also called Least Significant Bit (LSB). Always RIGHTMOST digit.
Need 8 bits to represent 256 colors ( 28 = 256). Total number of bits needed to represent the screen is then:
600 x 800 x 8 = 3,840,000 bits (or just under 4 Mbits) Your video card must have at least this much memory on it. 1 Mbits = 1024 x 1024 = 210 x 210 = 220 . 1 Kbits = 1024 = 210.
Subtraction table
borrow in
bin 0 0 0 0 1 1 1 1 x 0 0 1 1 0 0 1 1 y 0 1 0 1 0 1 0 1
borrow out
bout 0 1 0 0 1 1 0 1 d 0 1 1 0 1 0 0 1
Discuss this method in comparison with previous method from the class to create a subtractor
Signed-magnitude representation
Also called, sign-and-magnitude representation A number consists of a magnitude and a symbol representing the sign Usually 0 means positive, 1 negative
Sign bit Usually the entire number is represented with 1 sign bit to the left, followed by a number of magnitude bits
For this reason the signed-magnitude representation is not as popular as one might think because of its naturalness
0 and positive numbers: 0000-4999 Negative numbers: 5000-9999, where 9999 is minus 1.
Twos-complement representation
Just radix-complement when radix = 2 Used a lot in computers and other digital arithmetic circuits 0 and positive numbers: leftmost bit = 0 Negative numbers: leftmost bit = 1 To find a numbers complement just flip all the bits and add 1 See graphical view Fig. 2.3, p. 40.
Unsigned Numbers
DECIMAL CODES
Excess 3
Not a weighted code, but is also self-complementing Since code follows standard binary counting sequence, standard binary counters can easily be made to count in excess-3
Biquinary code
Uses more than 4 bits First 2 bits indicate whether the number is in the range 0-4 or 5-0
One-hot
Last 5 bits indicate which of the five numbers in the selected range is represented
Also one-hot
Advantage: error-detection property. If any 1 bit in a code word is accidentally changed to the opposite value, the resulting code word doesnt represent a decimal digit at all flagged as error.
UNICODE
UNICODE is a 16-bit code for representing alphanumeric data. With 16 bits, can represent 216 or 65536 different symbols. 16 bits = 2 Bytes per character.
0+3=3.
1+3=4 etc
Always two 1s
Decimal codes
You should be able to design binary to Gray code converter in both directions
Space of codes for 7 bits with code words and non-code words
Hamming Codes
Binary multiplication
Grammar school method for decimal: add a list of shifted multiplicands computed according to the digits of the multiplier Same method can be used in binary For two unsigned operands, the only possible values of the multiplier digits are 0 and 1
Thus its trivial to form the shifted multiplicands
Long Division
Homework problem 1
Convert the following binary numbers to decimal:
1011011.0110 00110.11001
Homework problem 2
Convert from decimal to binary:
0.5
73.426 290.9
11 011.101 1
Homework problem 4
Calculate 191+141 (Lets first convert these to binary as an exercise.) Verify in decimal 210 109, calculate first binary numbers. Verify.
Homework problem 5 1. Discuss how to convert hex, binary integers to Decimal 2. Discuss how to convert decimal integers to hex, binary 3. Discuss how to convert hex to binary, binary to Hex 4. Explain why N binary digits can represent 2N values, unsigned integers 0 to 2N-1.
sources
Bob Reese Wakerly Other from internet