Output is ignoring decimal part using bcdiv

Output is ignoring decimal part using bcdiv
php
Ethan Jackson

Code:

<?php $a = "38.5"; $result = bcdiv(bcadd($a, "6"), "2", 100); echo $result; ?>

Showing output:

22.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000

Expected output:

22.2500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000

Answer

<?php $a = "38.5"; $result = bcdiv(bcadd($a, "6", 100), "2", 100); echo $result; ?> Solved!!.

Related Articles