Search code examples
ctypesconstantspicmplab-c18

C18: Representation of LONG and FLOAT constants in code


Is a special representation needed for long and float numbers in the code?

In computer programming with C/C++ we put an f letter after a float typed constant number to distinguish it from double type. In C18 language, should/must we do the same thing?

float   fPi = 3.14f;  // Do we put this "f" in C18 language?
double dbPi = 3.14;

What about the long type?

int  iMyInt  = 32767;
long lMyLong = 32768?;  // Do we use any marking for long-type?

Solution

  • mcc18 does a few things slightly different from the ANSI standard:

    • integer literals take on the smallest possible type, unless annotated otherwise. So 100 is a char, 300 is an int, 32768 is a long.

    • double and float are the same type; both are software-emulated 32-bit IEEE floating points.

    For both of these points and more info see the User's Guide .