I want to use a macro definition to implement a simple conversion utility as shown here
Do numerical macros store integers by default? If yes, would I need to have a type cast to a double/floating point type and rounding to achieve what I want here?
#define MM_TO_POINT(mm) 2.83464567*mm
It's a macro -- all it does is take every occurrence of "MM_TO_POINT(bob)" and turn it into "2.83464567*bob". C will later interpret 2.83464567 as a double-precision number. But it doesn't "return" anything, it's just an expression.
Macros are nothing more than find-and-replace rules that are done before the compiler sees the code.
This is how some example usages would be replaced:
Now a more "interesting" case:
MM_TO_POINT(23) --> 2.83464567*23
x = MM_TO_POINT(y); --> x = 2.83464567*y;
(This is why macro "arguments" should always be in extra brackets.)
x = MM_TO_POINT(a + 5); --> x = 2.83464567*a + 5;
However, macro's are a very dumb tool. Why not use a (template) function to achieve the exact same result?