D
Dann Corbit
Keith Thompson said:[...]Dann Corbit said:With memory at low, low prices it seem hard to come up with sensible
reasons to prefer float over double for the vast majority of
applications.
However much memory you've got, there will still be times (probably
rarely) when being able to store twice as many numbers is worthwhile.
Very much so. However, often the interface between the two types
is more common on ingress/egress. *Every* variable in the program
can be considered a 'temporary intermediate' to be acted on at
double precision.
There is also a built-in paradox.
In the situations where float helps the most, it is the worst choice.
For example, suppose that your matrix is too large to fit into RAM using
double. So you switch to float. But a large matrix using float
precision is far more likely to suffer numerically than a smaller one
(where the float speed is not needed).
The number of operations in matrix multiply is O(N^3), so if N is {for
instance} 100, then the number of operations will be proportional to
1,000,000. If N is 1000, then the number of operations will be
proportional to 1,000,000,000. As you can see, in the places where
space becomes the most scarce, the operation count goes through the
roof. So the accumulated rounding error becomes a more and more serious
problem. Of course, there are cases where there is simply no choice but
to use float because the double matrix will not fit into RAM, and it is
not sparse. In those cases, it is really important to analyze the
stability of the calculation so that loss of precision does not render
the answer worthless {and you don't even know it}. (IOW, it's time to
put Dik Winter on the payroll).
;-)