I am having some data calculation on my client side, which I want to validate on the server end. Let's say my calculated value result is 34.55
(34.55).toFixed(1) gives me 34.5
Strangely, (34.555).toFixed(1) gives me 34.6
number_format(34.55, 1, '.', '') gives me 34.6
Can anyone suggest me an exact equivalent of either of the functions?
round(1.95583, 2); // 1.96
round( 1.55, 1, PHP_ROUND_HALF_DOWN); // 1.5
round( 1.54, 1, PHP_ROUND_HALF_DOWN); // 1.5
round( 1.55, 1, PHP_ROUND_HALF_EVEN); // 1.6
round( 1.54, 1, PHP_ROUND_HALF_EVEN); // 1.5
if you have any questions, ask
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With