I’m trying to learn C from a Ruby/PHP/Java background, and I’ve found that you almost always explicitly cast things (at least in tutorials). Like, I always see things like
double x, y;
x = 1.0;
/*...*/
y = x*5.0;
However, it seems that on my Mac’s version of GCC, automatic casting works.
Is leaving the .0 on things just a matter of style, or do some C compilers not autocast?
A constant has the type it is being assigned to:
explicit cast:
implicit cast:
type promotion:
vs