ASCII (American Standard Code for Information Interchange)
- 7-bit character code
- values: 0-127
Representing Sound
- For the computer to process the sound, it needs to be converted into binary.
- Convert the captured sound unto digital signal using microphone.
Representing Number
- In a computer system numbers are represented by a string of bits called Binary Number.
Number System
1. Decimal (Base 10) Number system
- 10 symbols: 0-9
- Uses positional notational
- 2. Binary (Base 2) Number system
- Binary number system has two symbols: 0 and 1, thus the base used is 2
Decimal to binary: Divide the number repeatedly by 2 until we get '0' as the quotient and remainders are written in reverse.
Example:
(23)10= ()2
23/2=11 r:1
11/2=5 r:1 Read from below
5/2=2 r:1 10111
2/2=1 r:0
0/2=0 r:1
(23)10= (10111)2
Binary to decimal (Use the weighted sum method)
Example:
(10111)2 = ( )10
=1*24+1*22+1*21+1*20
=16+4+2+1
=23
(10111)2 = (23)10
3. Hexadecimal (Base 16) Number System
Uses 16 symbols: 0-9,A-F
0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F
Hexadecimal to BinaryExample:
(56)16= (01010110)2
Binary to hexadecimal
Divide the bits into 4
(01010110)2= ()16
0101 ] 0110
=1*22+1*20 =1*22 + 1*21
=4+1 =4+2
=5 =6
(111000)2 = (56)16
Hexadecimal to decimal
(56)16= ()10
5*161+ 6*160
80+6
86
(56)16= (86)10
Decimal to hexadecimal
Convert the decimal into binary and then convert to hexadecimal
(86)10= ()2
86/2=43 r:0
43/2=21 r:1
21/2=10 r:1 read from below:
10/2=5 r:0 1010110
5/2=2 r:1
2/2=1 r=0
0/2=0 r=1
(86)10= (1010110)2
(1010110)2= ()16
Divide into 4bits
101 ] 0110
=1*4 + 1*1 =1*4+1*2
=5 =6
(1010110)2= (56)16
4. Octadecimal (Base 8) Number system
- It uses 8 symbols: 0-7
Octadecimal to Binary
Example:
(32)8= (11010)2
Binary to Octadecimal
Divide the bits into 3
(11010)2= ()8
010 ] 11
=1*21 =1*21 + 1*20
=2 =2+1
=3
(11010)2= (32)8
Octadecimal to decimal
(32)8= ()10
=3*81+ 2*80
=24+2
=26
(32)8= (26)10
Decimal to Octadecimal
Convert the decimal into binary and then convert to Octadecimal
(26)10= ()2
26/2=13 r:0
13/2=6 r:1
6/2=3 r:0 read from below:
3/2=1 r:1 11010
0/2=2 r:1
(26)10= (11010)2
(11010)2= ()8
Divide into 3bits
11 ] 010
=1*21+1*20 =1*21
=3 =2
(1010110)2= (32)8
If there are N bits in the binary number, the range of the number is: 0- 2N-1
Number Representation- Signed
- The leftmost bit is used to indicate the sign:
- 0 for positive
- 1 for negative
- Positive values have identical representation in all system.
- Negative Number have different representations
- Sign-and-magnitude
- 1's-complement
- 2's-complement
- 1's-complement
- Negative values are obtained by complementing each bit of the corresponding positive number.
- 2's-complement
- obtain by forming bit complement of the number, then add 1
- It is the most efficient way to carry out addition and subtraction operations.
- Addition
- Rules:
- 0+0=0
- 1+0=1
- 1+1=10 (binary for 2)
- 1+1+1=11 (binary for 3)
- Subtraction
- Rules:
- 0-0=0
- 1-0=1
- 1-1=0
- 0-1=1 (Borrow 1)
- For subtraction, first we convert it to addition by changing the signs of the bits.
- Range: -2n-1 to 2n-1-1
- 4bits: -8 to +7
- Overflow
- It occurs when the answer doesn't fit in the range given
- Overflow occurs when 2's-complementary numbers of same sign are added and the result has the opposite sign.
- (+A) + (+B) = -C
- (-A) + (-B)= +C
- Sign Extension
- If it is a positive bit numbers add zero in the front
- Ex: 001 can be written in five bits by adding 2 zeros in the front i.e., 00001
- If it is a negative bit numbers add one in the front
- Ex: 101 can be written in five bits by adding 2 ones in the front i.e., 11101
- Character Representation
- It uses 7-bit codes
No comments:
Post a Comment