Hi,
I'm getting this warning message when I compile my C program. I'm learning for my intro to programming class, so I'm a newbie.
The message is the subject of this posting.
Warning: Trucation from 'double' to 'float'
The code for the function I'm getting the message in is.
float emp_calc(char code, float hrs, float bns)
{ //this is where my trouble lies
float made;
float g = 9.1; //get the warning "truncation from 'double' to 'float' here
float s = 12.5;
float m = 14.25;
switch(pay_code)
{
case 'G':
made = (float)hrs * g + bns;
break;
case 'S':
made = (float)hrs * s + bns;
break;
case 'M':
made = (float)hrs * m + bns;
break;
default:
printf("\nError: You must input G, S, or M for the pay_code");
}
return(made);
}
I have no idea what the message means, but I figured it had to do with forcing the right side of my assignments to float, so I added the (float) before it. But I have no idea whether I'm using it right.
Thanks one and all for your help.
Tojam