php calculate float HELP!!

Posted by apis17 on Stack Overflow See other posts from Stack Overflow or by apis17
Published on 2010-04-18T09:54:57Z Indexed on 2010/04/18 10:03 UTC
Read the original article Hit count: 352

Filed under:
|
|
|

help!! i have weird math calculation here. hope someone will explain.

$a = 1.85/100;
$b = 1.5/100;
$c = 1.1/100;
$d = 0.4/100;
$e = 0.4/100;
$f = 0.4/100;
$g = 0.4/100;

$h = $a + $b + $c + $d + $e + $f + $g;

echo $h*100 ."<br>";
$i = $h-$a;
$i = $i-$b;
$i = $i-$c;
$i = $i-$d;
$i = $i-$e;
$i = $i-$f;
$i = $i-$g;

echo $i;

last $i value should be 0 but it returns 6.93889390391E-18

© Stack Overflow or respective owner

Related posts about php

Related posts about math