title: float arithmetic and x86 and x64 context
body: <p>We are running some code in both VisualStudio process context (x86 context) and out of VisualStudio context (x64 context). I notice the following code provides a different result in both context (100000000000 in x86 and 99999997952 in x64)</p>
  
  <pre><code>float val = 1000f;
  val = val * val;
  return (ulong)(val * 100000.0f);
  </code></pre>
  
  <p>We need to obtain a ulong value from a float value in a <strong>reliable</strong> way, no matter the context and no matter the ulong value, it is just for hashing purpose. I tested this code in both x64 and x86 context and indeed obtained the same result, it looks reliable:</p>
  
  <pre><code>float operandFloat = (float)obj;
  byte[] bytes = BitConverter.GetBytes(operandFloat);
  Debug.Assert(bytes.Length == 4);
  uint @uint = BitConverter.ToUInt32(bytes, 0);
  return (ulong)@uint;
  </code></pre>
  
  <p>Is this code reliable?</p>