Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   int format double arg calculations (http://www.go4expert.com/forums/int-format-double-arg-calculations-t667/)

musicmancanora4 28Mar2006 20:48

int format double arg calculations
 
Hey guys imtrying to calculate a figure but i get an error int format double arg
i want to calculate the sizetotal but also round off the sizetotal. How can i do that?




Code:

#define MINE_DENSITY 0.6

void placeMines(char minefield[MAX_GRID][MAX_GRID], unsigned size)
{

  float sizetotal;
 
 
  sizetotal = size * MINE_DENSITY;
 
 
  printf("%d", sizetotal);

}


coderzone 28Mar2006 23:36

Re: int format double arg calculations
 
It shouldnt be an error I guess. It should be warning.

Try writing
sizetotal = (float)(float)size * MINE_DENSITY;

and

printf("%f", sizetotal);


All times are GMT +5.5. The time now is 12:56.