Quote:
|
Originally Posted by Phil_Lutz
You Constant (#define) can be a floating point value.
but....
when you apply it in your program the result will be an int.
ie.
#define CONSTANT 1.5
int adjust_speed(int speed_in)
(
int speed_out;
speed_out = (speed_in/CONSTANT);
return speed_out; //sends back an int
)
|
however, the floating-point constant forces the processor to do floating point math, which is slower. in this case, using
Code:
#define CONSTANT 3/2
is better, because the processor can use integer math, which is faster.