-
Notifications
You must be signed in to change notification settings - Fork 8k
Closed as not planned
Description
Description
I have this code:
<?php
addAmount(50.00, 'update', 112.99);
function addAmount(float $addedValue, ?string $type, float $baseAmount): string
{
if ($addedValue) {
$baseAmount += $type == 'fixed' ? $addedValue : $baseAmount / 100 * $addedValue;
}
var_dump(
$baseAmount,
round($baseAmount, 2),
number_format(169.485, 2, '.', ''),
number_format($baseAmount, 2, '.', ''),
);
return number_format($baseAmount, 2, '.', '');
}In PHP 8.3, If I run this code, the result is:
float(169.48499999999999)
float(169.49)
string(6) "169.49"
string(6) "169.49"
But if I run this same code in PHP 8.4, the result is:
float(169.48499999999999)
float(169.48)
string(6) "169.49"
string(6) "169.48"
PHP Version
8.4.3
Operating System
Ubuntu 22.04
samucadsantos