I have a little game that requires me to calculate the difference between two decimal numbers. In some cases, it seems to blow up on me. For example, if I try to subtract 6.5-6.49, I expect to get 0.01, but instead I get 0.0099999999999998, which caused other calculations downstream to mess up. Here's the code I'm using:
$mytime=6.4861111111111;
$mytime=round($mytime, 2); //Should=6.49 now?
CPtime=6.5;
$timediff=($CPtime-$mytime);
Since I am rounding $mytime it should = 6.49, right? so howcome when I subtract CPtime (6.5) and mytime (6.49) I get 0.0099999999999998 and not 0.01??
Basil