Programmable Logic Controllers. Su Chen Jonathon Lin
Чтение книги онлайн.
Читать онлайн книгу Programmable Logic Controllers - Su Chen Jonathon Lin страница 19
Scientific notation is a common form of expressing very large or very small numbers. It expresses numbers in two parts: fractional part and power of ten. Some examples are:
4.56789 x 104 | for 45678.9 |
2.356 x 10-5 | for 0.00002356 |
The floating-point format is very similar to scientific notation. It also consists of two parts: mantissa and exponent. The mantissa has a fixed number of digits to express the significant digits of the number. The exponent has two digits for expressing the signed power of ten. It determines the direction and the number of places the decimal point must be moved with respect to the most significant digit for finding the actual decimal number being expressed. Table 3.12 shows the floating-point expression with its corresponding decimal and scientific notation.
PLCs use two words to represent a floating-point number in binary (Figure 3.10). The numbers are stored in memory in 3 parts — the sign, the exponent, and the mantissa; the base is assumed to be 2 or binary.
IEEE Standard 754 is a technical standard for floating-point computation established in 1985 by the Institute of Electrical and Electronics Engineers (IEEE). IEEE floating-point numbers have three basic components: the sign, the exponent, and the mantissa.
Table 3.12: Floating point, decimal, and scientific notation
Decimal | Floating-Point | Scientific Notation |
---|---|---|
9876.54 | 9.87654 +03 | 9.87654 x 103 |
0.000345 | 3.45000 -04 | 3.45000 x 10-4 |
–23.456 | –2.34560 +01 | –2.34560 x 101 |
–0.004567 | –4.56700 -03 | –4.56700 x 10-3 |
Figure 3.10: Representing a fl oating-point number in binary
3.11.1The Sign Bit
The sign bit is the most significant bit. The value of 0 denotes a positive number; 1 denotes a negative number.
3.11.2The Exponent
The exponent field needs to represent both positive and negative exponents. To do this, a bias is added to the actual exponent in order to get the stored exponent.
3.11.3The Mantissa
The mantissa, also called the significand, represents the precision bits of the number. It is composed of an implicit leading bit and the fraction bits. To find out the value of the implicit leading bit, consider that any number can be expressed in scientific notation in many different ways. For example, the number 5.6 can be represented as any of these:
5.6 x 100
0.056 x 102
5600 x 10-3
In order to maximize the quantity of representable numbers, floating-point numbers are typically stored in normalized form. This puts the radix point after the first non-zero digit. In normalized form, 5.6 is represented as 5.6 x 100.
Example 3.17: Find the effective range
6497.3 = 6.4973 x 103
0.000075 = 7.5 x 10-5
The effective range of IEEE floating-point numbers:
Binary | Decimal | |
---|---|---|
Single precision (32 bits) | ± (2 – 2-23) x 2127 | ~ ± 1038.53 |
Review Questions
1. Describe the characteristics of a number system.
2. What is the base number of a number system?
3. What four number systems do PLCs use?
4. List the counting symbols of the binary system.
5. List the counting symbols of the octal system.
6. List the counting symbols of the decimal system.
7. List the counting symbols of the hexadecimal system.
8. Write the corresponding binary numbers of the decimal numbers from 0 to 10.
9. What is the octal number system?
10. Write the corresponding octal numbers of the decimal numbers from 0 to 15.
11. Write the corresponding binary numbers of the octal numbers from 0 to 17.
12. Convert the octal number 34748 to its equivalent decimal number.
13. Write the corresponding hexadecimal numbers of the decimal numbers from 0 to 15.
14. Write the corresponding binary numbers of the hexadecimal numbers from 0 to F.
15. Convert the hexadecimal number 67E16 to its equivalent decimal number.
16. Describe the generic procedure of converting a number from one number system to another number system.
17. Describe the technique of converting a decimal number to its equivalent in other number systems.
18. Convert decimal 532 to its binary equivalent.
19. Convert decimal 90 to its binary equivalent.
20. Describe how to convert a decimal number to its octal equivalent.
21. Convert decimal 357 to its octal equivalent.
22. Convert decimal 4367 to its octal equivalent.
23. Describe how to convert a decimal number to its hexadecimal equivalent.
24. Convert decimal 965 to its hexadecimal equivalent.
25. Describe how to convert a binary number to its decimal equivalent.
26. Convert 1101012 to its decimal equivalent.
27. Describe how to convert an octal number to its decimal equivalent.
28. Convert 6748 to its decimal equivalent.
29. Describe how to convert a hexadecimal number to its decimal equivalent.
30. Convert EC5816 to its decimal equivalent.
31. Describe how to convert a binary number to its octal equivalent.
32. Convert 101110012 to its octal equivalent.
33. Describe how to convert an octal number to its