int format double arg calculations

Discussion in 'C' started by musicmancanora4, Mar 28, 2006.

  1. musicmancanora4

    musicmancanora4 New Member

    Joined:
    Mar 9, 2006
    Messages:
    42
    Likes Received:
    0
    Trophy Points:
    0
    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);
    
    }
    
    
    
     
  2. coderzone

    coderzone Super Moderator

    Joined:
    Jul 25, 2004
    Messages:
    736
    Likes Received:
    38
    Trophy Points:
    28
    It shouldnt be an error I guess. It should be warning.

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

    and

    printf("%f", sizetotal);
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice