Download presentation

Presentation is loading. Please wait.

Published byKarina Davids Modified over 2 years ago

1
ICS312 Set 2 Representation of Numbers and Characters

2
Number Systems - Decimal System (base 10) Uses positional representation Each digit in a number is associated with a power of 10 based on its position in the number. The one's digit (zero power of 10) is the rightmost digit and the powers of 10 increase as you move to the left. 5,325 = 5 * 10 3 + 3 * 10 2 + 2 * 10 1 + 5 * 10 0 For the decimal system: 10 = base 10 digits are: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 The concept of positional representation applies to the binary and hexadecimal numbering systems as well.

3
Number Systems - Binary Number System Base = 2 2 Digits: 0, 1 Examples: 1001b = 1 * 2 3 + 0 * 2 2 + 0 * 2 1 + 1 * 2 0 = 8 + 1 = 9 1010 1101b = 1 * 2 7 + 1 * 2 5 + 1 * 2 3 + 1 * 2 2 + 1 = 128 + 32 + 8 + 4 + 1 = 173 Note: it is common to put binary digits in groups of 4 to make it easier to read them.

4
Number Systems - Hexadecimal Number System Used as a shorter, easier to read notation than binary. Base = 16 16 digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E,F Examples: 10h = 1 * 16 1 + 0 * 16 0 = 16 (decimal) 200h = 2 * 16^2 = 2 * 256 = 512 45h = 4 * 16^ 1 + 5 = 69 3Fh = 3 * 16 + 15 = 48 + 15 = 63

5
Converting from binary or hex to decimal: Use positional representation to expand the number and convert to decimal equivalent. Examples: 0011 1010b 015Eh

6
Converting from decimal to binary: Use repeated division by 2. The remainders give the binary digits, starting from the lowest power of 2. Examples: Convert Division Step Quotient/Remainder Binary Digits 14 104

7
Converting from hex to binary Rewrite each hex digit as its (4-digit) binary equivalent. Examples: Hex Value Binary equivalent 4Bh 32FFh F38Bh

8
Converting from binary to hex Rewrite each group of 4 binary digits as its hex equivalent. Pad zeroes on the left as needed. Examples: Binary Hex Equivalent 1101 1011 0100 0111 b 0110 1111 1010 1001 b

9
Converting from decimal to hexadecimal: It’s simplest to convert the decimal number to binary and then convert that binary number to hexadecimal.

10
Arithmetic Apply the same concepts as for decimal arithmetic to binary and hexadecimal arithmetic.

11
Binary Addition: Underlying examples: how carries work 1 + 1 b = 10b 1 + 1 + 1 b = 10b + 1 = 11b Examples: 0011b 0010 1101b + 1001b + 0101 1110b =

12
Hexadecimal Addition: Underlying examples: how carries work F + 1 h = 10h E + 2 h = 10h A + B h = 10d + 11d = 21d = 15h Examples: 4Ah + 5Bh = 4B7Fh + 2A93h =

13
Representing Integers in the Computer (1) Signed Numbers and Unsigned Numbers Most Significant Bit (MSB) leftmost or high-order bit (bit 15 or 7) Least Significant Bit (LSB) rightmost or low-order bit (bit 0)

14
Representing Integers in the Computer (2) Signed Integers Allows positive and negative integers to be represented MSB used to indicate sign: 0 = positive, 1 = negative Since 1 bit is used to represent the sign, only 7 or 15 bits can be used for the magnitude, with positive and negative values for each + one extra negative value: 1 byte = 8-1 bits = 2 7 => range = -128 to 127 2 bytes = 16-1 bits = 2 15 => range = -32,768 to +32,767

15
Representing Integers in the Computer (3) 1's Complement Formed by reversing (complementing) each bit of value. 2's Complement form Formed by adding 1 to 1's complement of a number. Examples: Express -9 in 2's complement form (8-bit) Add 9 and its 2's complement value, ignoring carries: What is 2's complement of –5? Calculate 9 - 5 using 2's complement form for –5, ignoring carries.

16
Intel's peculiar method of storing multibyte numbers in the computer Note: each hex digit is encoded in a nibble (4 bits). e.g., 1011 1010 = BAh Example of a multibyte number: 3A 4D is a 2 byte hex number The memory of the computer is numbered byte 0, byte 1, byte 2,.. For this example, if the number is stored at bytes 20 and 21, it is stored as follows: byte 20byte 21 4D 3A

17
Intel's peculiar method of storing multibyte numbers in the computer (Cont. 1) The address of the 2 byte word (a word is 2 bytes, a byte is 8 bits) is given as the lowest address used, which is byte 20. Note again that the bytes are stored in reverse order with the least significant byte at the lowest memory address and the most significant byte stored at the highest memory address.

18
Intel's peculiar method of storing multibyte numbers in the computer (Cont. 2) Example with a double word (= 2 words or 4 bytes). E.g., 32 4A 3F 22h This would be stored in memory as: memory contents:223F4A32 byte # in memory: 505152 53 The address for the (entire) number stored in memory is 50, which is the lowest memory address used.

19
Character Representation ASCII American Standard Code for Information Interchange Standard encoding scheme used to represent characters in binary format on personal computers 7-bit encoding => 128 characters can be represented codes 0-31 and 127 are control characters (nonprinting characters) control characters used on PC's are: LF, CR, BS, Bell, HT, FF

20
Character Representation (Cont.) ASCII characters codes are used for input and output. E.g., when the number 5, is entered on the keyboard, the value read into the processor is the ASCII character code 35h. In order to do numeric processing, the ASCII code must be converted to the true numeric value by subtracting 30h, which gives the value 5. Then, before the result can be displayed the numeric value must be reconverted to an ASCII code which can be displayed

21
Character Representation (Cont.) UNIDEC is a system (supported e.g by HTML) for representing characters employing 2 bytes per character. With 2 16 possible characters, it is possible to include characters of languages other that English, such as Chinese,Korean, Russian, etc.

Similar presentations

Presentation is loading. Please wait....

OK

Binary Arithmetic & Data representation

Binary Arithmetic & Data representation

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google

Ppt on cervical cancer vaccine Free download ppt on globalisation and the indian economy Ppt on electrical power generation system using railway track slides Ppt on types of ram and rom Ppt on condition monitoring of transformers Ppt on national education day nepal File type ppt on cyber crime unit Ppt on endangered species in india Ppt on electric current and circuits Converter pub to ppt online reader