Which calculates numbers faster, binary or FPU instructions?

Depends on many factors, such as what operation (add, sub, mul etc.) and the specific processors. Some processors can execute FPU code faster than integer and others can do the vice versa. Also the FILD and FISTP are pretty slow instructions and shouldnt be used heavily in time critical code as the CPU has to convert the floats into integers which is time consuming so if you are going to do simple integer arithmetic, the binary instructions are the way to go.

Also, most floating point instructions can't be paired. :)

Usually, if exact results are not needed an binary solution can be worked out which is faster than a similar FPU algo. If your working with numbers that can't fit in 32 bits, then the FPU is an easy choice in most cases.

As a general rule, single arithmetic instructions doing a similar operation (such as ADD and FADD) should be faster on the CPU. But this applies almost strictly to integer maths. When you need high precision (or a wide range of integers and/or fractions), you don't have a choice but to use the FPU.

A few years ago, I wrote a program requiring a lot of maths (including the usual arithmetic functions, trigonometric functions and square roots) using only the CPU and fixed point math with the equivalent of 5 decimal places and NO tables.

I later rewrote the program using the FPU and was surprised that the execution time was almost the same. Results were quite similar when a low level of precision was required, but the FPU version was definitely superior and much more flexible when more precision became necessary.

So your question about calculation speed is quite relative.

Raymond

A few years ago, I wrote a program requiring a lot of maths (including the usual arithmetic functions, trigonometric functions and square roots) using only the CPU and fixed point math with the equivalent of 5 decimal places and NO tables.

I later rewrote the program using the FPU and was surprised that the execution time was almost the same. Results were quite similar when a low level of precision was required, but the FPU version was definitely superior and much more flexible when more precision became necessary.

So your question about calculation speed is quite relative.

Raymond

Also, most floating point instructions can't be paired. :)

correct me if I'm wrong, but I think optimizing for the stupid PII is obsolete. Get the Athlon optimizing PDF, and you'll think my way ;)