Which operation should be faster on a x86 CPU on Linux and what are the average differences (in %):
unsigned int x, y, z;
x = y / z;
or:
double x, y, z;
x = y / z;
The operation on double will be executed by the FPU and the CPU may continue to other commands. Is it correct?
Does it depend on compilation flags (I'm using gcc with the -O3
flag)?
If your work is inherently integer-based, the int-float and float-int conversions may ruin any performance benefit. C's default conversion (truncation) can be particularly slow on older Intel chips.
Apart from that, there are correctness issues with your idea and that's probably sufficient reason not to do it.