Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!samsung!uunet!mcsun!ukc!inmos!conor@lion.inmos.co.uk From: conor@lion.inmos.co.uk (Conor O'Neill) Newsgroups: comp.lang.c Subject: Microoptimisations (Was Re: Efficient way to transform float to string) Message-ID: <13045@ganymede.inmos.co.uk> Date: 11 Dec 90 13:44:14 GMT References: <5906@stpstn.UUCP> Sender: news@inmos.co.uk Reply-To: conor@inmos.co.uk (Conor O'Neill) Organization: INMOS Limited, Bristol, UK. Lines: 19 In article <5906@stpstn.UUCP> 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.] In my working environment, it is faster to multiply by 10 than it is to perform two shifts and an add. A reasonable compiler is far more likely to be able to turn a multiply by a constant into shifts and adds _if_this_is_faster_ than vice-versa. A smart programmer will leave this sort of micro-optimisation to the compiler. --- Conor O'Neill, Software Group, INMOS Ltd., UK. UK: conor@inmos.co.uk US: conor@inmos.com "It's state-of-the-art" "But it doesn't work!" "That is the state-of-the-art".