New operator: /*

BLARSON at ecld.#eclnet BLARSON at ecld.#eclnet
Mon Aug 27 10:10:31 AEST 1984


From:  Bob Larson <BLARSON at ecld.#eclnet>

There is no need for a temporary:

d=((long)(a*b))/c;

of course, both this and your example have the disadvantage of the conversion
to long is done AFTER the multiply.  Better would be:

d= (long)a*b/c;

where all computation is done in long.

Best would be to specify optional (to compiler writer) optimization 
algorythms:

Multiplying two ints resulting in long should use special opcode to do this
where practical.

Dividing a long by an int resulting in int should use special opcode where
practical.

Obviously this should also apply to int/short and short/char where applicable.

Bob Larson <Blarson at Usc-Ecl.arpa>
-------



More information about the Comp.lang.c mailing list