Sunteți pe pagina 1din 40

Number System and Data Representation

By: H. Cruz Source: Basic IT Foundation by Albano, et. al

Numbers System (intro)


Computer circuits can respond only to binary numbers. Therefore all data programs must be coded into binary form. Binary are represented by base 2 number system: either 0 or 1 Decimal System are represented by base 10 number system from 0 to 9

A. Number System Conversion


Decimal Number System or base 10 represented from 0 to 9 Each position is represented by its quantity Ex: 725 - 5 represent the ones place value
2 represented by tens one 7 represented by One hundred values 5 * 100 = 5 2 * 101 = 20 7 * 102 = 700 725

Binary Number System


Binary number system represented by base 2 number system: either 0 or 1 Each digit in binary notation is associated with quantity except that each position is TWICE as the quantity associated with the position to its right. The right most represented with the quantity 1 The next position to the left is 2, The next position is associated with 4; The next position is association with 16 The next position is associated with 32

Binary number system Binary to Decimal (conversion)

Representation 1 1 0 1

Positions quantity One (20 = 1) Two (21 = 2) Four (22 = 4) Eight (24 = 8)

Representation 1 1 0 1

Positions quantity 1* 20 = 1 0 * 21 = 2 1* 22 = 4 1 * 24 = 8 13

Representation 1 0 0 1

Positions quantity 1* 20 = 1 0 * 21 = 0 0* 22 = 0 1 * 24 = 8 9

Convert the ff binary into decimal


1. 101 2. 11000 3. 01110 4. 10100 5. 110011

= = = = =

5 24 14 20 51

Conversion of Decimal to Binary


1. 8 = 100

8/2 4/2 2/2

Quotient 4 2 1

Remainder 0 0 1

Conversion of Decimal to Binary (cont.)


2. 37 = 100101 Quotient 37 / 2 18 18 / 2 9 9/2 4 4/2 2 2/2 1 1/2 0 Remainder 1 0 1 0 0 1

Convert the ff Decimal into binary number


1. 22 2. 56 3. 87 4. 45 5. 120

Hexadecimal Number System


Dump is the process of printing the actual contents of the memory. The output of dump include strings of binary digits. (very tedious job) Through hexadecimal notation, a string of bits maybe represented in a shortened for. The base or radix of hexadecimal number is from 0 to 9, and letters A to F Hexadecimal notation uses one character or symbol to represents 4 bits.

Hexadecimal to binary
0 0 2 A =
One ( 160) Sixteen (161)
Two hundred Fifty six (162) Four thousand ninety six (163)

10 x 160 = 10

2 x 161 = 32 0 x 162= 0 0 x 163 = 0 42

Octal number system


A string of 12 bits can be represented by 4 octal systems. Represented from 0 to 7

7 1 5 =
One ( 80 = 1 ) Eight (81 = 8) Sixty Four (82 = 64) 5 x 80 = 5 1 x 81 = 8 7 x 82 = 448 461

Table of Decimal, Binary, Hexadecimal and Octal


Decimal Binary 0 0000 1 0001 2 0010 3 0011 4 0100 5 0101 6 0110 7 0111 8 1000 9 1001 10 1010 11 1011 12 1100 13 1101 14 1110 15 1111 16 10000 Hexadecimal 0 1 2 3 4 5 6 7 8 9 A B C D E F 10 Octal 0 1 2 3 4 5 6 7 10 11 12 13 14 15 16 17 20

B. Number System Operations


1. Decimal base to Binary base continuous division by 2 Hexadecimal base or Octal Base System.

Study the given examples


1. What is 13 base 10 in _____ base 2? (continuous division by 2) 13 / 2 = 6 1 6/2 3 0 3/2 = 1 1 1/2 = 0 1 Answer: 1101 Exer: 129 base 10 is equal to 10000001 base 2

What is 54 base 10 in base 16


1. What is 54 base 10 in base 16? 36

54 / 16 = 3 / 16 =

3 0

6 3

2. What is 108 base 10 in base 16? 108 / 16 =

2. Binary Notation of Hexadecimal and Octal Notation

Hexadecimal Symbol represents the series of 4 bits, while Octal symbol represents a series of 3 bit In order to convert binary to decimal, must arrange the binary digits into groups of 4 Starting from the right most, arrange the binary digits into groups of 4 Converts each groups into hexadecimal by multiplying it by its position value and get the sum of each.

Ex: 101010101011012 to _________16


1. 10 2 1010 10(A) 1010 10(A) 1101 13(B) = 2AAB

2. 11 0110 01112 = ____367_______16

11 3

0110 0111 6 7

Binary to Octal conversion


Convert 10101010 (base2) it octal equivalent 1. Arrange the binary digits into groups of 3 10 101 010 2. For each group, convert each digit to hexadecimal by multiplying by its position value 10 101 010

Binary to Octal(3 bit)


1. How 17 base 8 represented in base 2

1
1 2

111 7

How 45 base 8 represented in base 2 100 101 4 5

Addition and Subtraction of Binary Numbers


0 + 0 0 Ex: 11 +100 111 + 0 1 1 1010 + 1100 10110 1 + 0 1 + 1 1 10

10110 + 10111 101101

Addition of Hexadecimal What is the result of ABC16 + 2AA16? Solution: 1 1 ABC16 10 11 12 2AA16 2 10 10 13 22 22 -16 -16 13 6 6
1.

Addition done by adding the given hexadecimal value. If the added hexadecimal value exceeds the base radix, subtract the radix and get the result. Add 1 to the next highest value of hexadecimal

616

Addition of Hexadecimal
1. What is the result of 2DE16 +

FED16? 2. What is the result of CADE + CAFE? 3. What is the result of AE12 + FACADE

4FE16 4 15 14 13 + 2ED16 2 14 2 1 1

Addition of Octal
What is the result of 7528 + 5678? Solution: 1 1 1 7 5 2 + 5 6 _7 13 12 9 - 8 -8 -8 1 5 4 1
1.

Add the given octal value. If the added octal values exceeds the base or radix, subtract the radix, and get the results, then, add 1 to the next highest value of octal. If there are extra decimal value to the next highest position, just bring down the remaining decimal value.

Octal Addition
1. What is the result of

51078 + 655678? Answer:


1

5 1 0 7 +6 5 5 6 7 7 10 6 7 14 -8 -8 7 2 6 8 6

Binary Subtraction
0 0 0 0 1 0borrow with 1 2. 10000(16) - 1111(15) 1 1 0 1 + 1 1 0

1. 1010(10) -

100(4) 110(6)

3. 100011 - 1111 10100

Subtraction of Hexadecimal
What is the result of 5238 3578? Answer: 5 (4) 2(1+8) =9 (3+8 =11) 3 5 7 1 4 48
1.

Subtract the given hexadecimal value if the hexadecimal minuend is less than the hexadecimal borrow to the next hexadecimal position. If any results change those decimal digits to its corresponding letters.

C. Fixed Point Number Representation


A. BCD (Binary Coded Decimal) Format

Is one which the decimal digits are stored in terms of their 4-bit binary equivalents. There are two (2) basic format: 1. Packed Format the decimal digit is stored in a sequence of 4-bit groups. The number 2004 0010 0000 0000 0100 2 0 00 4

Packed format (cont.)


In packed format, 1 byte represents a numeric values of 2 digits and the least significant 4 bits represents the sign. The pattern for zero is 1100 positive sign The pattern for one is 1101 - negative sign Ex: +689 Ex: -689 0110 0110 1000 1001 1000 1001

1100 1101

2. Unpacked Format also called zoned-decimal format.


Unpacked format, a decimal digit is stored in the low-order part of an 8-bit group and what is put into the high-order part is unimportant. Format stored as: 2004
uuuu0010 uuuu0000 uuuu0000 uuuu0100

2. Unpacked Format also called zoned-decimal format.


The high order part is called zone-bits. In case of the EBCDIC (Extended Binary Coded Decimal Interchange Code) used in high end mainframes, the zone bits would store (1111) base 2. However the high order part of the least significant digit represents the sign. The assigned bits for positive 1100 and negative are 1101; respectively Ex: +689 1111 0110 1111 1000 1100 1001
zone bit 6 zone bit 8 zone bit 9

2. Unpacked Format also called zoned-decimal format.


Ex: -689 1111 0110
zone bit 6

1111 1000
zone bit 8

1101 1001
zone bit 9

B. Positive Integer
Decimal number are usually converted first to the binary equivalent. If we have an 8 bit register, it may express integer decimal numbers between 0 and 28 -1 or 255. If we have a bit of 16 bit register, we can store integer decimal numbers between 0 and 216 -1 or 65536. The magnitude of the number that can be stored in a register is 28 -1 where n is the number of bits with the register of memory cell.

C. Negative number
There are two (2) ways of representing negative number: 1. Absolute value representation negative numbers can be represented by attaching an extra bit to indicate the sign bit (leftmost). The resulting format is called sign-magnitude format Ex: +16 = 0001 0000 (sign bit is 0 to indicate the plus sign)
-16 = 1001 0000 (sign bit is 0 to indicate the plus sign) (This format representing negative numbers is seldom use)

C. Negative number (cont.)


2. The complement representation of a number is the amount of necessary to add to a number to make it complete for a given number of system. Thus is binary= 0 is complement of 1 1 is complement of 0 The ones complement representation is where the bit is complemented: Ex: the ones complement of: 10011 is 01100

C. Negative number (cont.)


The twos complement is obtained by adding one to the ones complement. 01001 10110
+1 ____________

10111

Determine the Ones complement of the ff:


1. 1101110012 2. 0011011102 3. 11010101012 4. 1010110 5. 1111110

Determine the Twos complement of the ff:


1. 1101110111101 2. 01011101 3. 4510 4. 23410

S-ar putea să vă placă și