rounding - PHP Round unexpected result -
i have problem php round function. rounds function not working correctly:
$value = 562.92578125; round($value,1); // return 562.9 (correctly) round($value,2); // return 562.9299999999999 (wrong) round($value,3); // return 562.926 (correctly)
as workaround try use:
number_format(round($value, 1), 1); number_format(round($value, 2), 2); number_format(round($value, 3), 3);
also, have here: can rely on php php.ini precision workaround floating point issue
Comments
Post a Comment