[Coco] CoCo gcc project

KnudsenMJ at aol.com KnudsenMJ at aol.com
Mon Nov 3 16:28:00 EST 2003


In a message dated 11/3/03 12:00:31 AM Eastern Standard Time, 
rtaylor at bayou.com writes:

> Rather, the fastest "divide by two" is the Shift Right instruction, and the 
>  fastest "multiply by two" is the Shift Left instruction.  :)

I've written a lot of C code where I used shifts to divide or multiply a 
value by powers of 2.  I've also been told that in fancy modern compilers, you're 
better off to write it as a multiply or divide by 2, 4, 8, whatever, and let 
the compiler figure out whether, on the target CPU, a shift is faster than a 
MUL or DIV instruction.

If the value is floating point, then you *have* to use honest arithmetic.  
--Mike K.



More information about the Coco mailing list