Re: Simple question

From: Alastair J Neil (ajn@essex.ac.uk)
Date: 12/12/95


thus spake d hall


>Michael> I don't know if this works, but even if it does it's not the best
>Michael> way.  Try something like
>
>it does work with GCC, since it's smart enough to implicitly typecast.
>
>Michael> ch->player.height = ch->player.height * 3 / 4;
>
>this might save the work of typecasting, but it varies based upon the
>platform and compiler.

why should this vary from platfom and compiler?  The precedence of
operators is defined in the ansi standard.

Michael> for faster code and code that is sure to work (fastest would be to
Michael> use a bit shift after the multiply).  By the way, don't mess with
Michael> the order of operations by adding ()'s.  To work right this has to
Michael> perform the *3 before the /4.

yes, this would seem to be the most portible.


-- 
Ich habe Dinge gesehen, die ihr Menschen niemals glauben wuerdet. Gigantische
Schiffe, die brannten draussen vor der Schulter des Orion. Und ich habe C-Beams  
gesehen - glitzernd im Dunkeln nahe dem Tannhaeuser Tor. All diese Momente 
werden verloren sein in der Zeit...so wie Traenen im Regen.  Zeit zu sterben...



This archive was generated by hypermail 2b30 : 12/07/00 PST