At 10:33 AM 12/4/2003, Luc Le Blanc wrote:
Under CW 8.3, are floating-point expressions resulting from computations
involving defines evaluated at runtime or resolved by the compiler? If
the latter is true, is it performed at all optimatization levels
(including 0)?

#define Pi 3.14659265

float halpPi = Pi / 2.0;

Are constant subexpressions pre-resolved too?

The best way to tell is to look at the generated code using the "disassemble" command. It should be pretty obvious if the compiler isn't folding constant expressions. I just tried your example, and it looked like the compiler did precompute the pi/2 value.


You may not see folding in some situations, mainly ones where the order of operations affects the precision of the generated numbers. Also, if you use "float" variables, you may want to write your constants as "3.141519f" with the trailing "f" to avoid having items converted to double in expressions.

--
Ben Combee <[EMAIL PROTECTED]>
CodeWarrior for Palm OS technical lead
Palm OS programming help @ www.palmoswerks.com



-- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/

Reply via email to