www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/12/01/18:15:49

Message-ID: <32A2268E.3A09@gbrmpa.gov.au>
Date: Mon, 02 Dec 1996 08:56:39 +0800
From: Leath Muller <leathm AT gbrmpa DOT gov DOT au>
Reply-To: leathm AT gbrmpa DOT gov DOT au
Organization: Great Barrier Reef Marine Park Authority
MIME-Version: 1.0
To: "G.P. Tootell" <gpt20 AT thor DOT cam DOT ac DOT uk>
CC: djgpp AT delorie DOT com
Subject: Re: Optimization
References: <57hg9b$or5 AT kannews DOT ca DOT newbridge DOT com> <329C4CD4 DOT 7474 AT cornell DOT edu> <Pine DOT SUN DOT 3 DOT 90 DOT 961127095705 DOT 25056B-100000 AT coop10> <329C62F6 DOT 23F6 AT stud DOT warande DOT ruu DOT nl> <329E2E2B DOT 3D02 AT gbrmpa DOT gov DOT au> <57mflm$bta AT lyra DOT csx DOT cam DOT ac DOT uk>

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019