Which calculates numbers faster, binary or FPU instructions?
Posted on 2003-04-08 15:06:16 by CyberGuy
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.
Posted on 2003-04-08 15:13:57 by x86asm
Also, most floating point instructions can't be paired. :)
Posted on 2003-04-08 16:00:32 by S/390
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.
Posted on 2003-04-08 20:22:23 by bitRAKE
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.

Posted on 2003-04-08 22:42:25 by 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 ;)
Posted on 2003-04-09 12:41:42 by Ultrano