Академический Документы
Профессиональный Документы
Культура Документы
ASCII CODE
ASCII : American Standard Code for Information
Interchange
Use bit patterns of length seven to represent
Letters of English Alphabet : a – z and A – Z
Digits : 0 – 9
Punctuation Symbols : (, ), [, ], {, }, ’, ”, !, /, \
Arithmetic Operation symbols: +, -, *, <, >, =
Special symbols: (space), %, $, #, &, @, ^
27 = 128 characters can be represented by ASCII
CHARACTER REPRESENTATION: ASCII TABLE
The BINARY string 0110101 can have two meanings!
What are those?
1. The CHARACTER “5” in ASCII
2. The DECIMAL NUMBER 53 in BINARY Notation
UNICODE
Why UNICODE?
EBCDIC and ASCII are built around the Latin alphabet
Are restricted in their ability for representing non-Latin alphabet
Countries developed their own codes for native languages
UNICODE:
16-bit system that can encode the characters of most languages
16 bits = 216 = 65,636 characters
The Java programming language and some operating
systems now use Unicode as their default character
code
Downward compatible with ASCII and Latin-1 character
sets
BINARY
ARITHMETIC
BINARY ADDITION
0+0=0
0+1=1
1+0=1
1 + 1 = 10 (carry: 1)
BINARY ADDITION
Carry
0 1 1 0 1
1 0 1 1 1
BINARY ADDITION
Carry
0 1 1 0 1
1 0 1 1 1
0
BINARY ADDITION
1 Carry
0 1 1 0 1
1 0 1 1 1
0
BINARY ADDITION
1 Carry
0 1 1 0 1
1 0 1 1 1
0 0
BINARY ADDITION
1 1 Carry
0 1 1 0 1
1 0 1 1 1
0 0
BINARY ADDITION
1 1 Carry
0 1 1 0 1
1 0 1 1 1
1 0 0
BINARY ADDITION
1 1 1 Carry
0 1 1 0 1
1 0 1 1 1
1 0 0
BINARY ADDITION
1 1 1 Carry
0 1 1 0 1
1 0 1 1 1
0 1 0 0
BINARY ADDITION
1 1 1 1 Carry
0 1 1 0 1
1 0 1 1 1
0 1 0 0
BINARY ADDITION
1 1 1 1 Carry
0 1 1 0 1
1 0 1 1 1
0 0 1 0 0
BINARY ADDITION
1 1 1 1 1 Carry
0 1 1 0 1
1 0 1 1 1
0 0 1 0 0
BINARY ADDITION
1 1 1 1 1 Carry
0 1 1 0 1
1 0 1 1 1
1 0 0 1 0 0
BINARY SUBTRACTION
0-0=0
0 - 1 = 1 (with borrow)
1-0=1
1-1=0
BINARY SUBTRACTION
(borrow)
0 1 1 0 1
1
- 0 1 0 1 1 1
BINARY SUBTRACTION
(borrow)
0 1 1 0 1
1
- 0 1 0 1 1 1
0
BINARY SUBTRACTION
(borrow)
*
0 1 1 0 1
1
- 0 1 0 1 1 1
1 0
BINARY SUBTRACTION
(borrow)
* *
0 1 1 0 1
1
- 0 1 0 1 1 1
1 1 0
BINARY SUBTRACTION
(borrow)
* *
0 1 1 0 1
1
- 0 1 0 1 1 1
0 1 1 0
BINARY SUBTRACTION
(borrow)
* * *
0 1 1 0 1
1
- 0 1 0 1 1 1
1 0 1 1 0
BINARY SUBTRACTION
(borrow)
* * *
0 1 1 0 1
1
- 0 1 0 1 1 1
0 1 0 1 1 0
BINARY MULTIPLICATION
1 0 1 1
1 0 1 0
BINARY MULTIPLICATION
1 0 1 1
1 0 1 0
0 0 0 0
BINARY MULTIPLICATION
1 0 1 1
1 0 1 0
0 0 0 0
1 0 1 1
BINARY MULTIPLICATION
1 0 1 1
1 0 1 0
0 0 0 0
1 0 1 1
0 0 0 0
BINARY MULTIPLICATION
1 0 1 1
1 0 1 0
0 0 0 0
1 0 1 1
0 0 0 0
1 0 1 1
BINARY MULTIPLICATION
1 0 1 1
1 0 1 0
0 0 0 0
1 0 1 1
0 0 0 0
1 0 1 1
1 1 0 1 1 1 0
BINARY DIVISION
1 0 1 1 1 0 1 1
BINARY DIVISION
1
1 0 1 1 1 0 1 1
BINARY DIVISION
1
1 0 1 1 1 0 1 1
1 0 1
BINARY DIVISION
1
1 0 1 1 1 0 1 1
1 0 1
0 0 1
BINARY DIVISION
1
1 0 1 1 1 0 1 1
1 0 1
0 0 1 1
BINARY DIVISION
1 0
1 0 1 1 1 0 1 1
1 0 1
0 0 1 1
BINARY DIVISION
1 0
1 0 1 1 1 0 1 1
1 0 1
0 0 1 1
0 0 0
BINARY DIVISION
1 0
1 0 1 1 1 0 1 1
1 0 1
0 0 1 1
0 0 0
1 1
BINARY DIVISION
1 0
1 0 1 1 1 0 1 1
1 0 1
0 0 1 1
0 0 0
1 1 1
BINARY DIVISION
1 0 1
1 0 1 1 1 0 1 1
1 0 1
0 0 1 1
0 0 0
1 1 1
BINARY DIVISION
1 0 1
1 0 1 1 1 0 1 1
1 0 1
0 0 1 1
0 0 0
1 1 1
1 0 1
BINARY DIVISION
1 0 1
1 0 1 1 1 0 1 1
1 0 1
0 0 1 1
0 0 0
1 1 1
1 0 1
1 0
EXERCISE – BINARY ARITHMETIC
1 1 0 1 1 0 1 0
+ 1 1 1 - 1 1 1
1 0 1 1
X 1 0 101 1 0 1 1
ANSWER – BINARY ARITHMETIC
1 1 0 1 1 0 1 0
+ 1 1 1 - 1 1 1
1 0 1 0 0 0 0 1 1
1 0 1 1 1 0
X 1 0 101 1 0 1 1
0 0 0 0 1 0 1
1 0 1 1 0 1
1 0 1 1 0
PRESENTING
NUMBER
NUMBER REPRESENTATION
Different ways to represent numbers
Unsigned representation : non-negative integers
Signed representation : integers
Floating-point representation: fractions
UNSIGNED BINARY NUMBERS
Have 0 and 1 to represent numbers
Only positive numbers stored in binary
Sign
bit
SINGED BINARY NUMBERS
Smallest positive number 0 0 0 0 0 0 0 0 which
equals to 0
Largest positive number 0 1 1 1 1 1 1 1 which equals
to 127
+15 = 0 0 0 0 1 1 1 1
-15 = 1 1 1 1 0 0 0 0
1 1 1 1 0 0 0 1
What is the SMALLEST and LARGEST
signed binary numbers that can be
stored in 1 BYTE
0 1 1 1 1 1 1 1 +127
. . . . . . . .
0 0 0 0 0 0 1 1 +3
0 0 0 0 0 0 1 0 +2
0 0 0 0 0 0 0 1 +1
0 0 0 0 0 0 0 0 0
1 1 1 1 1 1 1 1 -1
1 1 1 1 1 1 1 0 -2
1 1 1 1 1 1 0 1 -3
. . . . . . . .
1 0 0 0 0 0 0 1 -127
1 0 0 0 0 0 0 0 -128
TWO’S COMPLIMENT BENEFITS
One representation of zero
Arithmetic works easily
Negating is fairly easy
TWO’S COMPLEMENT REPRESENTATION
Write down two’s complement representation for the
decimal numbers 39 and -39.
RANGES OF INTEGER REPRESENTATION
8-bit unsigned binary representation
Largest number: 1 1 1 1 1 1 1 12 = 25510
Smallest number: 0 0 0 0 0 0 0 02 = 010
Size in
Type Range
Bits
19 ÷ 2 = 9 Remainder 1
9÷2=4 Remainder 1
4÷2=2 Remainder 0
2÷2=1 Remainder 0
1÷2=0 Remainder 1
1910 = 100112
FRACTIONS IN DECIMAL
0.825 X 2 = 1.650 1
0.650 X 2 = 1.300 1
0.300 X 2 = 0.600 0
0.600 X 2 = 1.200 1
0.82510 = 0.11012
19.82510 = 10011.11012
FLOATING POINT REPRESENTATION OF
FRACTIONS
Mantissa Exponent
11011.101 = 1.1011101 x 24
Base
FLOATING POINT FORMAT IN 1 BYTE
Radix Point
.
1 (-ve)
Store 21/8 in floating point notation
21/8 10 = 10.001 = 1.0001 x 21
0 0 0 0 1
0 1 0 0 0 0 0 1
1 0 1 1 1 0 1 0
CONVERT FP BINARY TO DECIMAL
Convert Exponent
1 0 1 1 1 0 1 0
Exponent = 011
=3–3=0
CONVERT FP BINARY TO DECIMAL
Apply Sign
1 0 1 1 1 0 1 0
Answer : -15/8
ROUND-OFF ERRORS
3.3125 = 11.0101
= 1.10101 x 21
0 1 0 0 1 0 1 0 1
ROUND-OFF ERRORS
0 1 0 0 1 0 1 0 1
1.1010 x 21 = 11.0102
11.010 = 3 + 1/4 = 31/4
0 1 1 1 1 1 1 1
0 0 0 0 0 0 0 0
1 0 0 0 0 0 0 0
1 1 1 1 1 1 1 1
Size in
Type Range
Bits
3.4E-38 to 3.4E+38
Float 32
Six digits of precision
1.7E-308 to 1.7E+308
Double 64
Ten digits of precision
3.4E-4932 to
Long
80 3.4E+4932
double
Ten digits of precision
IEEE FLOATING POINT FORMAT
Note
S – sign bit (1 for negative number and 0 for positive
number)
L – leading bit (always 1 in a normalized, non-zero
mantissa)
EXAMPLE : IEEE FP REPRESENTATION
Represent -100100101001.0012
-100100101001.0012 = 1.00100101001001 x 211
Sign : 1
Biased exponent : 11 + 127 = 138 = 100010102
Fractional part of mantissa :0.00100101001001000000000
1 10001010 00100101001001000000000
IEEE FP REPRESENTATION
Represent following numbers using IEEE
Floating point representation.
32.562510
-1 0 1 0 1 1 1 0 1 1 0 . 1 0 1 0 1 0 2
1 1 1 0 0 0 0 1 0 1 0 1 0 1 0 1 . 1 1 1 0 0 0 12
QUESTIONS
1 Which of the following is the range of integers which
can be represented using two’s complement notation
on a 16-bit register?
-32768 to +32768
-65536 to +65536
-65536 to +65536
-32767 to +32767
-32768 to +32767
2 What is the binary equivalent of the hexadecimal
number ABCD?
-65535
+32768
+65535
+32767
-65536
4 The equivalent in hexadecimal to the decimal
number 973 is
4BC
CB4
6D
6CD
3CD
5 The equivalent in binary to the hexadecimal
number A7FE is
101101111111110
1010011111111110
1010100101111110
101101111111111
1011011111101110
6 The equivalent in binary to the decimal number
4.625 is
100.001
100.110
100.111
100.101
100.1001
7 Which unsigned binary number in the result of the
subtraction of unsigned binary number 00101101
from the unsigned binary number 10111001?
01110011
10001100
00001100
01110100
10001101
8 The result of the addition of the unsigned binary
number 101.101 by the unsigned binary number
1011.110 is
11110.111
10001.011
10000.111
10001.111
10000.011
9 The result of the subtraction of binary number
11101.110 from the binary number 101101.101 is
111.001
1111.001
1111.111
111.111
111.101
10 The binary number 1011011011101 is equivalent
to (consider the decimal, octal and hexadecimal
number systems)
16DD
13335
16CC
5855
5851
11 The decimal number 6949 is equivalent to
(consider the binary, octal and hexadecimal
number system)
1010010011011
17449
1F23
1101100100101
17445
12 Which binary number in the form of two’s
complement is the result of the subtraction of
binary number 100011 from the binary number
1110101?
1001101
1001110
1001101
1010010
01110101
Consider the following binary patterns
13
A : 01010100
B : 00110111