title: Typecasting in C and use of parentheses
body: <p>I have these variables </p>
  
  <pre><code>distance = 945
  speed = 614
  </code></pre>
  
  <p>I want to get the time in hours and minutes so I divide distance/speed in order to get the hours. Now, if I want minutes as an integer I have the following code:</p>
  
  <pre><code>int minutes;
  minutes = (float) (distance%speed) / speed * 60;
  </code></pre>
  
  <p>This expression gives the value of 32 minutes, however, when I first tried, I wanted to make the code more "readable" and I tried the following options that gave me 0:</p>
  
  <pre><code>minutes = (float)  ( (distance%speed) / speed * 60 );
  minutes = (float) ( (distance%speed) / speed  ) * 60;
  </code></pre>
  
  <p>Note that the parentheses are added and are in different places, so why using parentheses in places that look fine to me interfere with the calculation and sets the value of 0 in the variable. I guess it has to do with the typecasting process, but the parentheses are in places that are supposed to make clearer the expression.</p>
  
  <p>I have the right answer and the program works properly but I want to understand this for future occasions because I spent a little time playing with the parentheses. Thank you</p>