Today PHP claims that 30.26 - 30.26 = -3.5527136788005E-15
My calculator (and common sense) says that it should equal 0. Both numbers being used in the calculation were taken from a MySQL database, data type is varchar(255). Taking this into account with floatval() doesn't seem to do the trick. Anybody know what's going on here?
/* this is what the table looks like...
__________________________________________
|uid |AccountNumber| Total| Paid|
__________________________________________
|51 |3255 | 30.26| 30.26|
__________________________________________
*/
$q = "SELECT Total, Paid FROM Account WHERE AccountNumber='3255';";
$r = mysqli_query($db, $q);
$vars = mysqli_fetch_array($r);
$balance = floatval($vars['Total']) - floatval($vars['Paid']);
echo $balance;
OUTPUT
-3.552713678805E-15