Simple question about doing math on Defined macros

Hi all,

Say I define something with the #define command, then later I want to divide a float or long number by that. Example:

#define BASE_LENGTH 20
float average = 240.32;
long average2 = 2432443;

average = average/BASE_LENGTH;
average2 = average2/BASE_LENGTH;

would this cause any problems involving opposing data types?

Sorry if this has been answered, but I can't seem to find the answer to this elsewhere, Thanks.

It will use the datatype it would use if you had typed it in. In this case, an int. In this case, the int would be converted to a float (at compile time!) to perform the calculation.

If you want to specify things, make it explicit:

#define BASE_LENGTH 20  /* int */
#define BASE_LENGTH1 20.0 /* float */
#define BASE_LENGTH2 20L /* long int */
#define BASE_LENGTH3 20 UL /* unsigned long int */

makes perfect sense, thank you