I have some code, which checks if a paid amount on our account is the same as it should be based on the bought items.
Here is some "Pseudocode":
$income = $this->getIncome();
$invoiceSum = $order->getInvoiceSum();
if($income != $invoiceSum ) echo "Error";
which gives me the "Error" output, even if the values are the same.
The value of $income is from a Rest API (JSON), where the $invoiceSum is calculated by my code based on the net values all ordered products multiplied by the tax rate.
If i do:
echo $income . " " . gettype($income) . "<br>";
echo $invoiceSum . " " . gettype($invoiceSum) . "<br>";
I get:
19.71 double
19.71 double
Which is what I expect.
So I tried to calculate as intvalues (=Cent instead of €). And now the weird part starts:
echo intval($income * 100);
echo intval($invoiceSum * 100);
and i get:
1970
1971
Hm? How to fix this, so i get the correct value?