Path: utzoo!attcan!uunet!taumet!steve From: steve@taumet.com (Stephen Clamage) Newsgroups: comp.lang.c Subject: Re: Efficient way to transform float to string Message-ID: <537@taumet.com> Date: 10 Dec 90 16:11:14 GMT References: <5906@stpstn.UUCP> Organization: Taumetric Corporation, San Diego Lines: 15 lerman@stpstn.UUCP (Ken Lerman) writes: >2 -- Rather than multiplying by 10, shift left two, add the original > and shift left again. (A smart compiler might do this for you.) > [Some might say that a reasonable compiler should do this for you.] Except that on some machines shifting is not cheap. On some machines an integer multiply by 10 is faster than two shifts and an add along with creating an intermediate result. A good rule is to leave it up to the compiler until performance tests prove you must do low-level coding like this. In that case, be sure to conditionalize the code for the particular compiler. -- Steve Clamage, TauMetric Corp, steve@taumet.com