I saw a calendar program written in C which just says 100. instead of 100.00. The program compiled without any issues.
My question is how is this legal. Shouldnt the C compiler not complain that there are no decimals after the .?
Advance thanks for your answers!
Because section 6.4.4.2 of the language standard, “Floating constants” , defines them thusly:
Bottom line, all of the following would be valid floating point literals meaning “zero”:
0.
.0
0.0
(Your “100.” would be a valid
floating-constant, as it is adecimal-floating-constantconsisting of afractional-constant(omitting the optionalexponent-partandfloating-suffix); it is adigit-sequencefollowed by a period, which is valid for afractional-constantas by the second line of that noteable’s definition.)