Mail Archives: djgpp/1997/02/27/12:49:03
Robert Humphris <r DOT humphris AT indigo-avs DOT com> wrote:
>I think that they are both the same! The speed ups with maths occur at
>multiplicaton/division time
>when you do the old bit shifts (<< & >>) instead.
>
>If this is wrong, will some one please tell me, as I don't want to be
>labouring upder misinformation
>
>Rob Humphris
This is normaly not true when programming in C, or C++ since most
compiler will optimize all division/multiplication with constants that
is a power of two to shift's anyway so
foo = bar / k;
where bar is variable integer, and k is a constant which is a power of
two will be converted into:
foo = bar >> log(k) / log(2);
So using shiftings for the sake of optimaization is normaly wasted,
and often leads to less self-explaining code.
=/=\=/=\=/=\=/=\=/=\=/=\=/=\=/=\=/=\=/=\=/=\=/=\=/=\=
How to kill a daemon: for(;0;)
Kurt. Programmer Funcom/R&D
The above expressions is not ment to represent Funcom.
- Raw text -