Mod returning strange value
<p>I am new to programming and am trying to write a program that works out a percentage and then displays the answer formatted dependant on the result.</p>

<pre><code>if(percent % 1 == 0.0)
{
    sw.Write(" {0}%", (int)percent);
}
else
{
sw.Write((" {0:f1}%", percent);
</code></pre>

<p>The percent values in this case are 11, 14, 12, 6 and 4. In all but 14 it displays as whole numbers but with 14 it displays as 14.0. If I watch percent the numbers will come up 11.0 12.0 etc but with 14 it is 14.000000000000004 and is therefore displaying incorrectly. Is this some quirk or am I just not programming it correctly? Regards Barry</p>
