title: Why is only the numerator cast to float to obtain a float quotient while dividing two integers?
body: <p>I am just starting out with Objective-C,and with C in general,so I suppose this is a C question as well.It's more of a <strong>why</strong> question rather than a <strong>how</strong> question.</p>
  
  <p>I noticed that while dividing two integers ,the decimal part is rounded down to <code>0</code> even though the result is a float.The sources I followed suggest the following approach to deal with this:</p>
  
  <pre><code>float result = (float) numerator / denominator;
  </code></pre>
  
  <p>I want to know now <strong>why</strong> this works. Two things especially.<strong>1)</strong> if you have to cast the numerator, why don't you have to cast the denominator as well? <strong>2)</strong> Why can't you just cast the whole thing? What I tried first was</p>
  
  <pre><code>float result = (float) (numerator / denominator);
  </code></pre>
  
  <p>But this again rounded the decimal part to <code>0</code>. What is the reason?</p>