Mail Archives: djgpp/1996/12/01/18:15:49
G.P. Tootell wrote:
>
> |> Actually, this is even faster if you:
> |> c = 1 / (x * y);
> |> a1 = b1 * c;
> |> a2 = b2 * c;
> |> a3 = b3 * c;
> |> A divide takes 39 cycles on a normal double divide, a mul takes 3
> |> cycles.
> |> Using your method, you have 3 divides (117 cycles) and one mul for 120
> |> cycles.
> |> Using the second method, you have 39 + 9 cycles, or 48... :)
> |>
> |> Leathal.
>
> except you forgot that if c isn't a float then you may well round the
> value of c down so much as to adversely affect the calculation of a1-3.
> and if c is a float then the code probably becomes slower than before
> i dunno.
Well, you would be mad to declare c as an int, and do an inverse
multiply
on it... :) Besides, if it was an int, I would have written the code
as:
c = (int) (1 / (x * y)); (assuming x and y _are_ floats/doubles)
Leathal.
- Raw text -