0

Have written a simple PHP program to get data from a database to an accounting program. Therefore I need to do some calculations. And one of them goes completely wrong.

<?php
$prijs = 480.00;
$nvh = 432.00;
$prov = 40.34;
$btw = 7.66;

$over = $prijs - ($nvh + $prov + $btw);
$tmp = ($nvh + $prov + $btw);

echo $prijs."\n";
echo $tmp."\n";

echo $prijs - $tmp."\n";
echo $over."\n";

?>

The result should be $over == 0 and $prijs - $tmp should also be 0.
But I get the following output:
480
480
-5.6843418860808E-14
-5.6843418860808E-14

Anybody? What is going on here?

2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by colweb
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.