| Integer Math |
Robert P. Munafo, 2002 Apr 22.
Prior to the Pentium and PowerPC, integer math (also called fixed point arithmetic) was a very important speed improvement for Mandelbrot programs.
The basic principle is very simple: pretend that your numbers are fractions with a specific denominator, and compute the values of the numerators.
For example, we will use the numbers 1.354 and 2.017. For ease of visualization, we will use a denominator of 1000. To represent these numbers as fractions, we use 1354/1000 and 2017/1000.
To perform addition you simply add the numerators:
1354/1000 + 2017/1000 = (1354+2017)/1000 = 3371/1000
To perform multiplication, you add the numerators, and then divide both numerator and denominator by 1000 (because the denominator of the answer always has to be 1000):
1354/1000 * 2017/1000 = (1354*2017)/1000*1000= 2731018/1000000
=~ 2731/1000
Notice that roundoff has to occur. In Mandelbrot iterations, roundoff seldom seems to make a significant difference (see the roundoff error entry for a complete explanation). To minimize its effect, one can use either "round towards negative infinity" or "round to nearest". The obvious "round towards zero" works too, only not quite as well.
Integer math works with the Mandelbrot Set because the iterations
Integer math techniques can be combined with most other forms of optimization. However, integer math cannot be used with the distance estimator method because the first deriviative iterates don't stay near the origin and therefore floating-point is required.
This work is licensed under a
Creative Commons Attribution 2.5 License
.