3 ms·
You can't have a float constant without an identifier? Huh? What is 0.5f, then?
by TazeTSchnitzel 11y ago
You can't have a float constant without an identifier? Huh? What is 0.5f, then?
- cremno 11y ago0.5f is a float_ing_ constant and has type float.
- TorKlingberg 11y agoThe article says "there can't be any floating constants.". What exactly does "floating" mean here?
- cremno 11y agoIt's short for floating point: https://en.wikipedia.org/wiki/Floating_point https://en.wikipedia.org/wiki/Floating_point
- TorKlingberg 11y agoSure, but I still don't understand how your first comment answers TazeTSchnitzel's. Does the preprocessor handle floating point constants or not?
- pascal_cuoq 11y ago> What is 0.5f, then? Since the article is about C preprocessor expressions and it says that in that context, there can't be any of them, I would say the answer is: “not a C preprocessor expression”.
- TazeTSchnitzel 11y agoThe article says this: > And there can't be any casts because you can't write a type without at least one identifier. [...] And since there can't be any casts, there can't be any floating constants. It says that there can't be floating-point constants because there aren't casts. But I just demonstrated a way to make a floating-point constant without a cast: 0.5f. Thus, surely, the statement that there can't be floating-point constants is wrong, since the only objection to them presented is that you need casts to construct them? Edit: Ah, now I see the problem. > An integer constant expression shall have integer type and shall only have operands that are [...], and floating constants that are the immediate operands of casts Since you can only have a float constant that's an immediate operand of a cast, and since you can't have casts, you can't have floats. Aha :)