title: Puzzled by different result from "same" type cast, float to int
body: <p>If I assign a value to a floating point computation to a variable first, then assign that to an unsigned int with implicit type casting, I get one answer.  But if I assign the same computation directly to the unsigned int, again with implicit type casting, I get a different answer.</p>
  
  <p>Below is sample code I compiled and ran to demonstrate:</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  
  
  int
  main( int argc, char** argv )
  {
      float   payloadInTons = 6550.3;
  
  
      //  Above, payloadInTons is given a value.
      //  Below, two different ways are used to type cast that same value,
      //  but the results do not match.
      float tempVal = payloadInTons * 10.0;
      unsigned int right = tempVal;
      std::cout &lt;&lt; "    right = " &lt;&lt; right &lt;&lt; std::endl;
  
  
      unsigned int rawPayloadN = payloadInTons * 10.0;
      std::cout &lt;&lt; "    wrong = " &lt;&lt; rawPayloadN &lt;&lt; std::endl;
  
  
      return 0;
  }
  </code></pre>
  
  <p>Does anyone have insight into why "right" is right, and "wrong" is wrong?</p>
  
  <p>By the way, I am using gcc 4.8.2 on Ubuntu 14.04 LTS, if it matters.</p>