user253985
user253985

Reputation: 13

double in C preprocessor directives

What is the differences between,

#define myvariable 1.25

and,

#define myvariable (double)1.25

while declaring a preprocessor directives in C.

Upvotes: 1

Views: 163

Answers (1)

paxdiablo
paxdiablo

Reputation: 881673

The difference is that the preprocessor will, when it sees myvariable, substitute in (double)1.25 rather than 1.25.

This will have no effect on your code (possibly bizarre edge cases notwithstanding) since 1.25 is already a double literal, as per C11 6.4.4.2 Floating constants /4:

An unsuffixed floating constant has type double. If suffixed by the letter f or F, it has type float. If suffixed by the letter l or L, it has type long double.

Upvotes: 5

Related Questions