For example, I have this line of code:
echo 10359023529 + 0.2137582935;
Why does this return:
10359023529.2
instead of:
10359023529.2137582935
echo 'Using PHP_ROUND_HALF_DOWN with 1 decimal digit precision' . PHP_EOL; var_dump(round( 1.55, 1, PHP_ROUND_HALF_DOWN)); var_dump(round(-1.55, 1, PHP_ROUND_HALF_DOWN));
The round() function rounds a floating-point number. Tip: To round a number UP to the nearest integer, look at the ceil() function. Tip: To round a number DOWN to the nearest integer, look at the floor() function.
Example #1 round() examples php echo round(3.4); // 3 echo round(3.5); // 4 echo round(3.6); // 4 echo round(3.6, 0); // 4 echo round(1.95583, 2); // 1.96 echo round(1241757, -3); // 1242000 echo round(5.045, 2); // 5.05 echo round(5.055, 2); // 5.06 ?>
Use: bcadd()
echo bcadd(10359023529, 0.2137582935, 10);
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