I have a question about floating constants in C.
In Java, the default type of floating point constants is double, so the following will result in a compilation error in java:
float f = 100.0;
This is due to the fact that floating-point constants are of type double by default and casting from double to float without a cast operator is a mistake, so we need to either add a case statement or put f at the end of the number.
So, why does this not cause an error in C, because floating-point constants are of type float by default, or because the compiler performs an implicit conversion with a down conversion (which does not require a type in C)
source
share