search

Home  >  Q&A  >  body text

2*-0.3+0.6 =1.1102230246252E-16 Who knows why?

Displays -0.3*2 0.6=1.1102230246252E-16 instead of zero, who knows why? Please give me some advice

Screenshot from 2020-06-11 20-51-54.png##

$x = [3, 0, 2];

$tArr = [0.2, 0.3, - 0.3];

$s = 0;

foreach ($x as $k => $e) {

$s = $ e * $tArr[$k];

echo $s . PHP_EOL;

}

孙博孙博1649 days ago951

reply all(0)I'll reply

No reply
  • Cancelreply