Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Upcoming SlideShare
What to Upload to SlideShare
What to Upload to SlideShare
Loading in …3
×
1 of 34

Fundamentals of Computers - Chapter 4

6

Share

Download to read offline

Fundamentals of Computers

Related Books

Free with a 30 day trial from Scribd

See all

Related Audiobooks

Free with a 30 day trial from Scribd

See all

Fundamentals of Computers - Chapter 4

  1. 1. © Oxford University Press 2016. All rights reserved. Fundamentals of Computers Reema Thareja
  2. 2. © Oxford University Press 2016. All rights reserved. Chapter 4Chapter 4 Number Systems and Computer Codes
  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
  4. 4. © Oxford University Press 2016. All rights reserved. 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
  6. 6. © Oxford University Press 2016. All rights reserved. Convert 169 into its binary equivalent Converting Decimal Number into Binary Form
  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
  8. 8. © Oxford University Press 2016. All rights reserved. Examples of Binary Addition 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
  10. 10. © Oxford University Press 2016. All rights reserved. Subtracting Two Binary Numbers Examples of Binary Subtraction
  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
  13. 13. © Oxford University Press 2016. All rights reserved. Examples of Binary Multiplication Multiplying Two Binary Numbers
  14. 14. © Oxford University Press 2016. All rights reserved. Dividing 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
  17. 17. © Oxford University Press 2016. All rights reserved. Convert 9890 into octal form Converting Decimal Number into Octal 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
  20. 20. © Oxford University Press 2016. All rights reserved. Convert 1239 into Hexadecimal Form Converting Decimal Number into Hexadecimal 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
  32. 32. © Oxford University Press 2016. All rights reserved. • Each decimal digit is the 4-bit binary equivalent with 3 (0011) added Excess-3 Code
  33. 33. © Oxford University Press 2016. All rights reserved. • A minimum change code, in which only 1 bit in the code changes from one code to the next • Non-weighted code • Steps to obtain Gray code:  Copy the MSB of the binary code as the MSB of the Gray code  Repetitively add MSB and the bit next to the MSB to get the corresponding bit for the Gray code Gray Code
  34. 34. © Oxford University Press 2016. All rights reserved. • Can represent characters (including punctuation marks, mathematical symbols, technical symbols, and arrows) as integers • Has several character encoding forms:  UTF-8: Uses only 8 bits to encode English characters. This format is widely used in email and on the Internet.  UTF-16: Uses 16 bits to encode the most commonly used characters. It can represent more than 65,000 characters.  UTF-32: Uses 32 bits to encode the characters. It can represent more than 100,000 characters. Unicode

×