Technical Considerations

32

Technical Considerations

as binary floating-point numbers. Binary floating-point numbers can represent real numbers exactly in relatively few cases; in all other cases the representation is approximate.

For example, 1/2 (0.5 in decimal) can be represented exactly in binary as 0.1. Other real numbers that can be represented exactly in decimal have repeating digits in binary and hence cannot be represented exactly, as shown below. For example, 1/10, or decimal 0.1 exactly, is 0.000110011 . . . in binary.

Errors of this kind are unavoidable in any computer approximation of real numbers. Because of these errors, sums of fractions are often slightly incorrect. For example, 4/3 Ð 5/6 is not exactly equal to 1/2 on any computer, even on computers that use IEEE standard arithmetic.

Fraction

Decimal approximation*

Binary approximation

1/10

0.1000000000à

0.000110011001100110011001101

1/2

0.5000000000à

0.100000000000000000000000à

4/3

1.333333333

1.01010101010101010101011

5/6

0.8333333333

0.110101010101010101010101

4/3 Ð 5/6

0.4999999997

0.100000000000000000000001

* 10 significant digits 23 significant digits à Exact value

The IEEE standard defines data formats for floating-point numbers, shows how to interpret these formats, and specifies how to perform operations (known as floating-point operations) on numbers in these formats. It requires the following types of floating-point operations:

basic arithmetic operations (add, subtract, multiply, divide, square root, remainder, and round-to-integer)

conversion operations, which convert numbers to and from the floating-point data formats

comparison operations, such as less than, greater than, and equal to

environmental control operations, which manipulate the floating-point environment

The IEEE standard requires that the basic arithmetic operations have the following attributes:

The result must be accurate in the precision in which the operation is performed. When a numerics environment is performing a floating-point operation, it calculates the result to a predetermined number of binary digits. This number of digits is called the precision. The result must be correct to the last binary digit.

If the result cannot be represented exactly in the destination data format, it must be changed to the closest value that can be represented, using rounding.

iMalc Manual

Page 38
Image 38
Apple 1.1.2 manual Technical Considerations