Efficient way to transform float to string
Stephen Clamage
steve at taumet.com
Tue Dec 11 03:11:14 AEST 1990
lerman at 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 at taumet.com
More information about the Comp.lang.c
mailing list