Chapter 3
Chapter 3
By: Behayilu M.
01000011 01101000 01100001 01101100 01100001 00100000 01010011 01101001 01101101 01101111 01101110 00100000 01000110 01101001 01101011 01100001 01100100 01110101
Chapter Three: Data Representation and Computer Arithmetic
1. BIT:
• Bits are the smallest units of data representation and can convey only two possible states 0 or 1;
2. BYTE:
• the basic “unit of data representation” in a computer system.
• It contains 8 bits.
3. Word:
• the number of bits that a computer process at a time or a transmission media transmits at a time.
4. Nibble:
• Group of 4 continuous bits
…cont’d
• A byte is then used as a unit of measurement in the computer memory, processing unit, external storage and
during communication.
• Bit
• Nibble
• Byte
• Kilo Byte
1 KB = 210 ≈ 1,024 Bytes
• Mega Byte
1 MB = 210 ≈ 1024KB = 1,048,576 Bytes
• Giga Byte
1 GB = 210 ≈ 1024MB = 1,048,576 KB = 1,073,741,824 Bytes
• Tera Byte
1 TB = 210 ≈ 1024 GB = 1,048,576
• Peta Byte
MB = 8,388,608 KB = 1,099,511,627,776 Bytes
• EXA Byte
• Zetta Byte
• Yotta Byte
Concept of Number Systems and Binary Arithmetic
• The number systems that are generally used by computers are: decimal, binary, octal, and
hexadecimal.
… Number System
• The remainders are to be read from bottom to top to obtain the binary equivalent.
4310 = 1010112
Number system Conversion
• Decimal to Octal
• Decimal numbers can be converted to octal by repeated division of the number by 8 while
recording the remainder.
• E.g. 47310 = ?8
• The remainders are to be read from bottom to top to obtain the octal equivalent.
47310 = 7318
Number system Conversion
• Decimal to Hexadecimal
• Decimal numbers can be converted to hexadecimal by repeated division of the number by 16 while
recording the remainder.
• E.g. 47310 = ?8
• The remainders are to be read from bottom to top to obtain the hexadecimal equivalent.
42310 = 1A716
Number system Conversion
2 6 2 5
101100101012 = 26258
…cont’d
• Octal to Binary
• To convert an octal number to binary, each octal digit is converted to its 3-bit binary equivalent
according to this table.
• E.g. 26258 = ?2
2 6 2 5
26258=101100101012
Number system Conversion
7 B 5
111101101012 = 7B516
…cont’d
• Hexadecimal to Binary
• To convert an hexadecimal number to binary, each hexadecimal digit is converted to its 4-bit binary
equivalent according to this table.
Binary 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111
Hex.Dec 1 2 3 4 5 6 7 8 9 A B C D E F
• E.g. 6A516 = ?2
6 A 5
6A516=110101001012
Number system Conversion
c. A1016 = ?10
0.25
*2 Exercise:
0 .50 1. Convert 12.2510 to Octal
*2 2. Convert 17.5 to Hexadecimal
1 .00
The Binary equivalent of .25(10) is .01(2)
Number system conversion with fractions
• Converting Binary, Octal and Hexadecimal numbers with fractions to Decimal.
• To convert binary, octal and hexadecimal with fractions to decimal number, we just need to add the
product of each digit with its positional value.
• XYZ.UVb = (X*b2 + Y*b1 + Z*b0 + U*b-1 + V*b-2)10
• Exercise:
a. 1001.012 = ?10
b. 56.328 = ?10
c. FF.A16 = ?10
Number system conversion with fractions
• Group three/four digits together starting from the last digit of the integer part, and if there is less number of digits add some
zeros in the beginning.
• Group three/ four digits together starting from the first digit of the fractional part, and if there is less number of digits add some
zeros to the end.
• Covert each group of the integer and the fractional part to their equivalent Octal/hexadecimal and collect the results by adding
point (.) to separate the integer part from the fractional part.
1 2 .5 2 8
• A . A 8 16
10 1 0 1 1 0
Binary Arithmetic
• Binary Subtraction:
• Subtraction and Borrow, these two words will be used very frequently for the binary subtraction. There are four rules of
binary subtraction.
With borrow
•
Binary Arithmetic
• Binary Multiplication:
• Binary multiplication is similar to decimal multiplication. It is simpler than decimal multiplication because only 0s and 1s are
involved. There are four rules of binary multiplication.
• Example – Multiplication:
Binary Arithmetic
• Binary Division:
• Binary division is similar to decimal division. It is called as the long division procedure.
Computer Coding Methods
• As computers use binary numbers for internal data representation, computer codes use
• In binary coding, every symbol that appears in the data is represented by a group of bits
• Commonly used computer codes are BCD, EBCDIC, and ASCII Codes
Computer Coding Methods
• BCD (6-bits)
• EBCDIC
• ASCII
• for n-bit sign magnitude representation the range of values • Example 2: Represent –24 using 8-bits sign magnitude
that can be represented are representation
• – (2 n-1-1 ) to (2 n-1-1). 24 = 00011000
-24 = 10011000
One’s Complement
• In one’s complement representation, all positive integers are represented in their correct binary
format. However, for negative numbers, it can be obtained by complementing every bit in the original
representation.
• Each 0 is transformed into a 1 and each 1 into a 0. Each 0 is transformed into a 1 and each 1 into a 0.
• For example:
+3 = 0000 0011 • Example 1: Add -4 and +6 using 8-bits one’s complement
• A negative number represented in two’s complement is obtained by first computing the one’s
complement and then add one.
• Each 0 is transformed into a 1 and each 1 into a 0. Each 0 is transformed into a 1 and each 1 into a 0.
• For example:
+3 = 0000 0011 • Example 1: Add 4 and -3 using 8-bits Two’s complement
-3 = + 4 is 00000100
2’s comp= One’s comp +1 - 3 is 11111101
00000001
End