GoFiler Legato Script Reference
Legato v 1.5b Application v 5.24b
|
Table of Contents | < < Previous | Next >> |
Chapter Three — Data Types and Operators (continued)
One of the most fundamental differences in data types relates to integers versus real or floating-point numbers. Integers are very exact, as a value of ‘1’ will always be one. Integers always represent whole numbers. Conversely, real numbers may have precision but are not necessarily exact. A good example is the real number equivalent of 1/3, which results in 0.3333333. This is a “repeating” number that cannot be accurately represented. Integers are appropriate for counting items or indexing lists while floating-point numbers are more suitable for mathematical operations or accounting. Finally, there is a computer oddity with the representation of real numbers. The computer technique for storing and working with floating-point numbers uses a binary mantissa and exponent (similar to scientific notation such as 3.14E10). The translation into and out of decimal format can sometimes lead to minor errors.
When integers and real numbers are mixed in a mathematical operation, data may be lost or otherwise truncated. For example:
int x;
float y;
y = 2.0;
x = 1/y;
In this case, x will contain a value of 0 rather than 0.5 because the result of operation is stored in an integer data type. The real number is truncated to fit the integer specification and information is lost. Therefore, it is essential to pay attention to data types, both those of the variables involved in an operation and that of the variable in which the result is being stored.
Table of Contents | < < Previous | Next >> |
© 2012-2024 Novaworks, LLC. All rights reserved worldwide. Unauthorized use, duplication or transmission prohibited by law. Portions of the software are protected by US Patents 10,095,672, 10,706,221 and 11,210,456. GoFiler™ and Legato™ are trademarks of Novaworks, LLC. EDGAR® is a federally registered trademark of the U.S. Securities and Exchange Commission. Novaworks is not affiliated with or approved by the U.S. Securities and Exchange Commission. All other trademarks are property of their respective owners. Use of the features specified in this language are subject to terms, conditions and limitations of the Software License Agreement.