I was working with floats in PHP when I noticed that one server I am on treats them differently. How do I gain consistency between the two servers?
EXAMPLE CODE
$var = "6.15";
var_dump(round($var, 2));
var_dump(floatval($var));
ini_set('serialize_precision', 3); //I don't understand this and would rather not use it
var_dump(round($var, 2));
var_dump(floatval($var));
SERVER 1 RESULTS - Linux - PHP Version 8.1.12
float(6.1500000000000004)
float(6.1500000000000004)
float(6.15)
float(6.15)
SERVER 2 RESULTS - Linux - PHP Version 7.3.25
float(6.15)
float(6.15)
float(6.15)
float(6.15)