What's going on?! Subtraction works fine until I get to 0.1 - 0.1. I'm in visual c# 2008 using the nonoba.com API.
Console.WriteLine("hit! " + Users[targetNum].character.health + " : " + player.character.profile.attackPower);
Users[targetNum].character.health -= player.character.profile.attackPower;
Console.WriteLine("health! " + Users[targetNum].character.health);
output:
hit! 0.1 : 0.1
health! 1.490116E-08
Thanks all - I might use the decimal type, as I'm normally adding/subtracting nice "round" numbers. For now I'll just go with:
if (Users[targetNum].character.health <= 0.00001)
By the way I knew this wasn't really going to be a "bug" in c# - I thought it would either by a bug in my code or some lack of understanding, which it was.
Having read all the recommended reading, I'm going to conclude that my folly was due to normally using the ActionScript Number type, which maybe has a decimal rather than binary floating point - anyway, it would never give this output.