And I say again, you can prove this to be completely true, for all
hardware, including specially optimised hardware? Imagine a system
that does addition on an 8080 and division on a Pentium. Which
operation is faster?
Well, if the 8080 is wildly overclocked (Z80s, which is code
compatible with the 8080, can go as fast as 32 MHz, last time I
checked) and the division is one by zero on a Pentium then the 8080
might still be faster ;-)
Also, remember (I hope) that a Pentium works with a relatively long
pipeline and there will be a distinct difference between throughput
and latency.
My statement doesn't provide for such hypothetical systems. I work
with real systems and I'm confident enough (armed with the knowledge
about how divisions and additions are carried out in hardware) to
state that divisions will not be quicker than additions.
I will grant you that my statements are not universally valid (what
statement is?).
Agreed
But its perfectly possible to build hardware with
a FP unit which runs at higher clock speeds than the main cpu (in fact
it probably makes sense, FP operations often take more clock cycles).
So I can easily envisage hardware on which addition and division were
of comparable speeds, or better.
I can envision such hardware as well. But I haven't actually _seen_
such hardware.
You're trying to undermine a solid programming practice by coming up
with counter examples that rely on hypothetical machines. I dare to
say that most programmers don't program for hypothetical machines but
real ones.
Or consider for instance floating point addition, and integer division
by two. Which is faster?
If the integer division is replaced by a single shift to the right
then it might be very close. But a shift is not a division.
Indeed. But no need to invoke magic. Today's hardware could do it.
The thing about assertions is, to make them into facts, you have to
prove them to be true.
Take Newton's F = M * A
It's good enough for "daily use" even though QM and relativety theory
have shown it to be not precise enough for the very fast or the very
small.
But that doesn't make it less helpfull, for "daily use".
On most real machines my statement about divisions and additions will
hold, but there might be some exceptions (although I believe most such
exceptions to be hypothetical).
Or you can program as if thats something you should not be worrying
about yet. Do you recall the three laws of optimisation?
There are many such sets but you're probably refering to the one which
starts with "law #1 Don't do it"