floating constants in C

Posted by Daziplqa on Stack Overflow See other posts from Stack Overflow or by Daziplqa
Published on 2010-05-24T01:25:31Z Indexed on 2010/05/24 1:30 UTC
Read the original article Hit count: 227

Filed under:
|
|
|

Hi floks, I have a question concerning floating constants in C.

In Java, the default type of floating point constants in double, so the following will causes a compilation error in java:

float f = 100.0;   // we either need to uses type case operator or put f at the end of the number constant.

This is because the default floating-point constants are of type double and casting from double to float without type cast operator is an error, so we need either add a type case operator or put f at the end of the number.

So, Why in C this doesn't produce an error, Is it because the default floating-point constants are of type float, or because the compiler do an implicit down-cast conversion (that doesn't requires type case operator in C)????

© Stack Overflow or respective owner

Related posts about java

Related posts about c