I understand what this code produce but I don't know what kind of syntax (or function) it is.
code
void main()
{
float af;
int a = 75;
int cov = 100;
af = a/cov;
printf("af: %f\n", af);
af = (float) a/(float) cov;
printf("af: %f\n", af);
}
output
af: 0.000000
af: 0.750000
Without the (float)
in front of the two int
variables, it would have done the division between integers (thus returning 0.0) and then converted it to float
, while with the (float)
it seems to temporarly convert a
and cov
to float and than perform the division.
What is this (type)
form?