1 / 49

Number Systems and Codes

3. Number Systems and Codes. Objectives. Explain the decimal number system. Explain integer numbers, fractional numbers, and real numbers. Describe the binary number system. Convert decimal numbers to binary and vice versa.

feo
Download Presentation

Number Systems and Codes

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 3 Number Systems and Codes

  2. Objectives • Explain the decimal number system. • Explain integer numbers, fractional numbers, and real numbers. • Describe the binary number system. • Convert decimal numbers to binary and vice versa. • Perform binary math operations such as add, subtract, multiply, and divide.

  3. Objectives • Explain the hexadecimal number system. • Convert binary numbers to hexadecimal numbers and vice versa. • Explain the octal number system. • Convert binary numbers to octal numbers and vice versa. • Explain the binary coded decimal number system and its use.

  4. Objectives • Convert decimal numbers to binary coded decimal. • Explain the Gray code number system and its use. • Explain ASCII and EBCDIC alphanumeric codes.

  5. Decimal Number System • Decimal number system: • Has ten (10) digits running from zero (0) through nine (9). • Decimal digits are 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9. • Each digit's value depends on the position of the digit within the number.

  6. Decimal Number System (Cont.) • Base,also called the radix: • Multipliers for the digits are numbers constructed of the number system (10 in the decimal system) raised to the appropriate power. • 10a 10 = Base or radix a = Power

  7. Decimal Number System (Cont.) • Values for the power of ten (10) numbers.

  8. Decimal Number System (Cont.) Example: 6310 = (6 × 103) + (3 × 102) + (1 × 101) + (0 × 100) = (6 × 1000) + (3 × 100) + (1 × 10) + (0 × 1) = 6000 + 300 + 10 + 0 = 6310

  9. Fractional Numbers • Fractional numbers: • Have weights that are negative powers of ten (10). Example: 0.812 = (8 × 10-1) + (1 × 10-2) + (2 × 10-3) = (8 × 0.1) + (1 × 0.01) + (2 × 0.001) = 0.8 + 0.01 + 0.002 = 0.812

  10. Real Numbers • Real numbers: • Have weights that are both positive and negative powers of ten (10). • Integer parts. • Fractional parts. • Value of digits: • Digits. • Digits' positions.

  11. Real Numbers (Cont.) Example: 547.165 = (5 × 102) + (4 × 101) + (7 × 100) + (1 × 10–1) + (6 × 10–2) + (5 × 10–3) = (5 × 100) + (4 × 10) + (7 × 1) + (1 × 0.1) + (6 × 0.01) + (5 × 0.001) = 500 + 40 + 7 + 0.1 + 0.06 + 0.005 = 547.165

  12. Real Numbers (Cont.) • Digits to the left of the decimal point represent the integer number. • Digits to the right of the decimal point represent the fractional number.

  13. Integer Numbers • Integer numbers: • Have weights that are positive powers of ten (10). • Can be positive or negative. • Zero is an integer number.

  14. Binary Number System • Binary number system: • Has a base, also called a radix, of two (2). • Only the digits 1 and 0 are present. • All binary numbers are created from combinations of these two digits.

  15. Binary Number System (Cont.) • Least significant bit (LSB): • Binary digit to the far right-hand side of the number. • Rightmost number has the smallest value. • Most significant bit (MSB): • Binary digit to the far left-hand side.

  16. Binary-to-Decimal Conversion • Converting binary-to-decimal: • Convert each bit to its equivalent decimal value. • Add all of these decimal values.

  17. Decimal-to-Binary Conversion • Convert integer part of a decimal number using: • Repeated division. • Successive division. • Convert fractional part using: • Repeated multiplication. • Successive multiplication.

  18. Decimal-to-Binary Conversion (Cont.) • Successive division method: • Integer decimal number is divided by two, repeatedly. • Remainders make up the new binary number.

  19. Decimal-to-Binary Conversion (Cont.) • Successive multiplication method: • Convert the fractional part of a decimal number to binary. • MSB of the binary number: • Decimal number is multiplied by two and the portion that is carried (if the product is greater than 0). • Process is continued until the decimal part of the number becomes zero.

  20. Binary Addition • Decimal number system: • Carry generated when the sum of two digits is equal to 10. • Binary number system: • Carry generated when the sum of two binary bits is equal to two.

  21. Binary Addition (Cont.) • Ways that binary bits are added and how the carry bitis generated: 0 + 0 = 0 0 + 1 = 1 1 + 1 = 0 with carry of 1 1 + 1 + 1 = 1 with carry of 1

  22. Binary Subtraction • In the decimal number system: • When the value of a digit is being subtracted (the subtrahend) is greater than the value of the digit that it is being subtracted from (the minuend), a borrow from the next higher column (the column to the left) is required.

  23. Binary Subtraction (Cont.) • Subtraction of binary numbers: • Ways binary bits are subtracted and when a borrow bitis required: 0 – 0 = 0 no borrow 1 – 1 = 0 no borrow 1 – 0 = 1 no borrow (1) 0 – 1 = 1 with a borrow of 1

  24. Binary Multiplication • In multiplication, the multiplicandis multiplied by each of the multiplierdigits. • Results of each higher multiplier digit are shifted one place to the left. • When each of the multiplicand’s digits have been multiplied by the multiplier digits, all of the numbers are added.

  25. Binary Multiplication (Cont.) • How binary bits are multiplied: 0 × 0 = 0 0 × 1 = 0 1 × 0 = 0 1 × 1 = 1

  26. Binary Division • Division: • How many times a number called the divisorcan be subtracted from another number called the dividend. • Similar to decimal division.

  27. Binary Division (Cont.) • Subtraction routine: • Continues until the remainder is less than the dividend. • Quotient: • Number of times the divisor can be subtracted from the dividend.

  28. Hexadecimal Number System • Hexadecimal number system: • Used in medium to larger programmable logic controllers (PLCs). • Often just called hex. • Used to display the PLC memory map and to carry out the math instructions. • Created by grouping four binary bits. • Hexadecimal numbers use base of 16 and require fifteen digits.

  29. Hexadecimal Number System (Cont.) • Uses the numbers zero (0) through nine (9) for the first ten digits. • Ten (10) through fifteen (15) are represented by letters A through F. • Digits representing 10, 11, 12, 13, 14, and 15 are displayed as A, B, C, D, E, and F respectively. • Capital letter H or the small letter h is placed at the end of a hexadecimal number.

  30. Hexadecimal Number System (Cont.) Hexadecimal Binary Decimal 0 0000 0 1 0001 1 2 0010 2 3 0011 3 4 0100 4 5 0101 5 6 0110 6 7 0111 7 8 1000 8 9 1001 9 A 1010 10 B 1011 11 C 1100 12 D 1101 13 E 1110 14 F 1111 15

  31. Hexadecimal Number System (Cont.) • To form hex numbers from binary numbers, group binary number bits in groups of four. • Swap out each group of four binary bits with its hex equivalent. Example: 111100010111 becomes 1111 0001 0111 which is transformed to F 1 7 or F13h.

  32. Hexadecimal Number System (Cont.) • Reverse the process to convert to binary. • Take each hex digit and swap it with the binary 4-bit equivalent. Example: The number 37Ah becomes 0011 0111 1010 or 001101111010.

  33. Octal Number System • Octal number system: • Has a base of eight. • Therefore, only the digits zero (0) through seven (7) are present. • Used to display the memory maps and carry out the math instructions in some MicroLogix controllers.

  34. Octal Number System (Cont.) Octal Binary Decimal 0 000 0 1 001 1 2 010 2 3 011 3 4 100 4 5 101 5 6 110 6 7 111 7

  35. Octal Number System (Cont.) • Form an octal number from a binary number by grouping binary number bits in groups of three. • Swap out each group of three binary bits with its octal equivalent octal digit. Example: • The number 11001111 becomes 011 001 111 which is transformed to 3 1 7 or 317O.

  36. Octal Number System (Cont.) • Reverse the process to convert to binary. • Take each octal digit and swap it with the binary 3-bit equivalent. Example: • The number 246 becomes 010 100 110 or 10100110. • The capital letter O is placed at the end of an octal number.

  37. Binary Coded Decimal (BCD) System • Each 4 bits of binary numbers are grouped to form a decimal number. • Four bit groups representing 10, 11, 12, 13, 14, and 15 are not valid numbers in the BCD number system. • Only digits zero (0) through nine (9) are valid.

  38. Binary Coded Decimal (BCD) System (Cont.) Binary Coded Decimal (BCD) Decimal 0000 0 0001 1 0010 2 0011 3 0100 4 0101 5 0110 6 0111 7 1000 8 1001 9

  39. Binary Coded Decimal (BCD) System (Cont.) • To convert a number from any number system to BCD, first convert the number to decimal. • Then, represent each decimal digit with a 4-bit binary number code.

  40. Gray Code • Servo control: • Closed-loop industrial control system that is used to control the speed and position of an electric motor shaft. • Optical encoders: • Generate codes that represent the angular positions of the motor shafts. • Usually in a format called Gray code.

  41. Gray Code (Cont.) • Gray code system: • Similar to binary. • Converted to binary prior to arithmetic operation. • Used for detecting the position of a motor shaft. • Only one digit changes state (turns on or off) as a number increments or decrements.

  42. Gray Code (Cont.) • Gray code system (continued): • Speed of the operation of a control system increases. • Only one digit changes with every rotation of the optical encoder disc attached to the motor shaft. • Difficulty in doing arithmetic operations.

  43. Gray Code (Cont.) Gray code Binary Decimal 0000 0000 0 0001 0001 1 0011 0010 2 0010 0011 3 0110 0100 4 0111 0101 5 0101 0110 6 0100 0111 7 1100 1000 8 1101 1001 9 1111 1010 10 1110 1011 11 1010 1100 12 1011 1101 13 1001 1110 14 1000 1111 15

  44. Alphanumeric Code • Alphanumeric codes represent: • Letters • Numbers • Special symbols

  45. American Standard Code for Information Interchange (ASCII) • 7-bit code • Used to represent alphabets, numbers, characters, and control codes in computer systems. • One hundred and twenty eight (27 = 128) different characters can be represented. • Data is often sent in bytes (groups of eight bits). • Eighth bit in one byte of transmitted data used for a parity bit.

  46. Extended Binary Coded Decimal Interchange Code (EBCDIC) • 8-bit code. • Alphanumeric code commonly encountered in computer mainframe equipment. • Two hundred and fifty six (28 = 256) different characters can be represented. • Uppercase and lowercase. • Numbers (1 thru 9). • Punctuation, control codes, and other characters. • Commonly called Extended ASCII.

  47. Alphanumeric Codes

  48. Control Codes

More Related