How can we type cast a double number to long. I am getting wrong value, when i am trying to type cast it to long.
int main()
{
int s=9;
double minuttakst=0.019000;
int takst_enhed=60;
double antal_minutter, beloeb;
antal_minutter = (double) s / (double)takst_enhed;
beloeb = ((double)((long)(((antal_minutter * minuttakst) * 10000.0) + 0.5)
)) / 10000.0;
printf(" \nbeloeb is :%lf\n",beloeb);
return 0;
}
The output of the program is 0.002800, but i should get it as 0.002900