Successfully reported this slideshow.
Upcoming SlideShare
×
1 of 34

Fundamentals of Computers - Chapter 4

6

Share

Fundamentals of Computers

See all

See all

Fundamentals of Computers - Chapter 4

3. 3. © Oxford University Press 2016. All rights reserved. • Computers are electronic machines that use binary logic. • This logic uses two different values to represent the two voltage levels (value 0 for 0 V and value 1 for +5 V). • The binary number system uses only two digits, 0 and 1. Binary Number System
5. 5. © Oxford University Press 2016. All rights reserved. Converting Binary Number into Decimal Form Convert (1101)2 into a decimal number Decimal number = 1 × 23 + 1 × 22 + 0 × 21 + 1 × 20 = 1 × 8 + 1 × 4 + 0 × 2 + 1 × 1 = 8 + 4 + 0 + 1 = 13
7. 7. © Oxford University Press 2016. All rights reserved. Rules of Binary Addition • 0 + 0 = 0 • 0 + 1 = 1 • 1 + 0 = 1 • 1 + 1 = 0, and carry 1 to the next more significant bit Adding Two Binary Numbers
9. 9. © Oxford University Press 2016. All rights reserved. Rules of Binary Subtraction • 0 − 0 = 0 • 1 − 0 = 1 • 1 − 1 = 0 • 0 − 1 = 1, and borrow 1 from the next more significant bit Subtracting Two Binary Numbers
11. 11. © Oxford University Press 2016. All rights reserved. Calculate 1011 − 1001 using two’s complement •Subtrahend = 1001 •One’s complement of subtrahend = 0110 •Two’s complement of subtrahend = 0110 + 1 = 0111 •Add the minuend and the two’s complement of the subtrahend Subtraction Using Two’s Complement
12. 12. © Oxford University Press 2016. All rights reserved. Rules of Binary Multiplication •0 × 0 = 0 •0 × 1 = 0 •1 × 0 = 0 •1 × 1 = 1 Multiplying Two Binary Numbers
15. 15. © Oxford University Press 2016. All rights reserved. • Base 8 number system which uses digits 0–7 • Extensively used in early mainframe computer systems • Less popular in comparison to binary and hexadecimal systems Octal Number System
16. 16. © Oxford University Press 2016. All rights reserved. Convert (123)8 into its decimal equivalent Decimal number = 1 × 82 + 2 × 81 + 3 × 80 = 1 × 64 + 2 × 8 + 3 × 1 = 64 + 16 + 3 = 83 Converting Octal Number into Decimal Form
18. 18. © Oxford University Press 2016. All rights reserved. • Base 16 number system • Symbols 0–9 represent values zero to nine, and A, B, C, D, E, F (or a–f ) represent values 10–15 • Prefix 0x is used for numbers represented in hexadecimal system Hexadecimal Number System
19. 19. © Oxford University Press 2016. All rights reserved. Convert 0x312B into its equivalent decimal value Decimal number = 3 × 163 + 1 × 162 + 2 × 161 + B × 160 = 3 × 4096 + 1 × 256 + 2 × 16 + B × 1 = 12288 + 256 + 32 + 11 = 12587 Converting Hexadecimal Number into Decimal Form
21. 21. © Oxford University Press 2016. All rights reserved. • Write the 4-bit binary representation of each hexadecimal digit • Convert 0xABCD into its binary equivalent (ABCD)16 = (1010 1011 1100 1101)2 Converting Hexadecimal Number into Binary Form
22. 22. © Oxford University Press 2016. All rights reserved. • Pad the binary number with leading zeroes (if necessary), so that it contains multiples of 4 bits • Convert the binary number 01101110010110 into its hexadecimal equivalent  After padding the binary number is 0001 1011 1001 0110  Substitute the appropriate hexadecimal digits for a group of four binary digits  The equivalent hex number = 1B96 Converting Binary Number into Hexadecimal Form
23. 23. © Oxford University Press 2016. All rights reserved. • Convert the hexadecimal number into its binary equivalent • Convert the binary number into its equivalent octal number • Convert (A1E)16 into its octal equivalent  Convert (A1E)16into its binary equivalent (10100001 1110)2  Now divide the binary number into groups of 3 binary bits and convert each group into its equivalent octal number. Thus, we have (5036)8 Converting Hexadecimal Number into Octal Form
24. 24. © Oxford University Press 2016. All rights reserved. • Convert the octal number into its binary equivalent • Convert the binary number into hexadecimal form • Convert (567)8 into its hexadecimal equivalent  (567)8 = (101 110 111)2  Form groups of 4 binary bits  (Left pad if required) and convert each group into hexadecimal number. Thus, we have (177)16 Converting Octal Number into Hexadecimal Form
25. 25. © Oxford University Press 2016. All rights reserved. Convert (10110.1110)2 into decimal (10110.1110)2 = 1 × 24 + 0 × 23 + 1 × 22 + 1 × 21 + 0 ×20 + 1 × 2−1 + 1 × 2−2 + 1 × 2−3 + 0 × 2−4 = 1 × 16 + 0 × 8 + 1 × 4 + 1 × 2 + 0 × 1 + 1 × 1/2 + 1 × 1/4 + 1 × 1/8 + 0 × 1/16 = 16 + 0 + 4 + 2 + 0 + 0.5 + 0.25 + 0.125 + 0 = 22.875 Working with Fractions
26. 26. © Oxford University Press 2016. All rights reserved. Convert (127.35)8 into decimal (127.35)8 = 1 × 82 + 2 × 81 + 7 × 80 + 3 × 8−1 + 5 × 8−2 = 1 × 64 + 2 × 8 + 7 × 1 + 3 × 1/8 + 5 × 1/64 = 64 + 16 + 7 + 0.375 + 0.078125 = 87.453125 Working with Fractions
27. 27. © Oxford University Press 2016. All rights reserved. • Required to encode negative numbers in the binary • Three widely used techniques are: In Sign-and-magnitude, MSB is set to 0 for a positive number or zero, and set to 1 for a negative number. The other bits denote the value or the magnitude of the number. In One’s Complement, first write the binary representation of the number’s positive counterpart and then negate each bit. In Two’s Complement, negate all the bits in the binary representation and then add 1 to the result. Signed Number Representation
28. 28. © Oxford University Press 2016. All rights reserved. • Used for encoding decimal numbers • Digits 0-9 are used • Each digit is represented by its own binary sequence of 4 bits • For example, decimal 7 is 0111 in BCD • Allows easy conversion to decimal digits for printing or display • Allows faster decimal calculations BCD Code
29. 29. © Oxford University Press 2016. All rights reserved. • Two types of BCD numbers are—unpacked and packed BCD  In unpacked BCD representation, only one decimal digit is represented per byte. The digit is stored in the lower nibble, and the higher nibble is not relevant to the value of the represented number. For example, Decimal 17 = 0000 0001 0000 0111.  In packed BCD representation, two decimal digits are stored in a single byte. For example, Decimal 17 = 0001 0111 (in BCD). BCD Code
30. 30. © Oxford University Press 2016. All rights reserved. • Stands for American Standard Code for Information Interchange • Seven-bit character code • ASCII characters are examples of unpacked BCD numbers • Values in ASCII codes are represented as their 4-bit binary equivalents stored in the lower nibble, while the upper nibble contains 011 • Most common format for text files in computers and on the Internet ASCII
31. 31. © Oxford University Press 2016. All rights reserved. • Stands for Extended Binary Coded Decimal Interchange Code • Eight-bit character-encoding technique used on mainframe • Supports a wider range of control characters than ASCII • EBCDIC characters are similar to ASCII characters. While the lower nibble contains the 4-bit binary equivalent the upper nibble is padded with 1111, instead of 011 EBCDIC