Why does this floating-point calculation give different results on different machines?
<p>I have a simple routine which calculates the aspect ratio from a floating point value. So for the value 1.77777779, the routine returns the string "16:9". I have tested this on my machine and it works fine.</p>

<p>The routine is given as :</p>

<pre><code>    public string AspectRatioAsString(float f)
    {
        bool carryon = true;
        int index = 0;
        double roundedUpValue = 0;
        while (carryon)
        {
            index++;
            float upper = index * f;

            roundedUpValue = Math.Ceiling(upper);

            if (roundedUpValue - upper &lt;= (double)0.1 || index &gt; 20)
            {
                carryon = false;
            }
        }

        return roundedUpValue + ":" + index;
    }
</code></pre>

<p>Now on another machine, I get completely different results. So on my machine, 1.77777779 gives "16:9" but on another machine I get "38:21".</p>
