strange problem in PHP?

Mohammad Shahid

New member
hi friends i am running below code in PHP to sum up values, but it is giving wrong sum value, please check where is the problem

<?php

$total_amount=80;
$total_amount+=5.6;
$total_amount+=0;
$total_amount+=-101;
//echo $total_amount; //gives -15.4

$total_rec=-15.4;
//echo $total_rec; //it is -15.4

$total_bal_amount= $total_amount-$total_rec;

echo $total_bal_amount; // gives -5.3290705182008E-15, it should give -30.8

?>

it is giving correct sum values in excel
80
5.6
0
-101
-15.4
-------
-30.8
 
Back
Top