Using C preprocessor concatenation to get number in exponential notation
c-preprocessor, concatenation
Solution
You're right, `-1` and `+1` are two preprocessing tokens, hence only the first is pasted to the `e`.
For me,
#define EXPO(num, sign, ex) num ## e ## sign ## ex
EXPO(1,,1)
EXPO(1,-,1)
EXPO(1,+,1)
worked with gcc-4.5.1.
Problem
Why does code: ``` #define EXPONENT(num, exp) num ## e ## exp EXPONENT(1,1) EXPONENT(1,-1) EXPONENT(1,+1) ``` after preprocessing changes into: ``` 1e1 1e- 1 1e+ 1 ``` and not into ``` 1e1 1e-1 1e+1 ``` ? I suspect it might be because -1,+1 are parsed as two tokens (?). However, how in that case obtain the latter result?