in some codes, i see that expressions such as:
3.14f,(for float)
2.64l(for long double)
is used. what is this typecasting method called as?
Printable View
in some codes, i see that expressions such as:
3.14f,(for float)
2.64l(for long double)
is used. what is this typecasting method called as?
It is not a typecast; it is just a way of specifying that the literal is of the particular type.
The reason for it is because by default, 2.31 for example, would be evaluated by the compiler as a double.
They're called a "suffix"
anything with a floating point is automatically a double foe the computer. here you say 3.14f, it means.. oh wait, it's not double, it is float. use it as a float!
also check out this discussion -
http://cboard.cprogramming.com/c-pro...icky-code.html
:D