Home > Blockchain >  How to limit showing digits after decimal
How to limit showing digits after decimal

Time:11-18

my software showing a Grand Total like this 2.00192, 3.65826 but I want it to show like 2.00, 3.65 My codes:

<td rowspan="2"><label for="date" ><?php echo display('grand_total')?>:</label>
                                  <label >
                                    <input type="hidden" id="orggrandTotal" value="<?php echo $calvat $itemtotal $servicetotal-($discount $pdiscount);?>" name="orggrandTotal">
                                    <input name="grandtotal" type="hidden" value="<?php echo $calvat $itemtotal $servicetotal-($discount $pdiscount);?>" id="grandtotal" />
                                    <span ><strong>
                                    <?php if($currency->position==1){echo $currency->curr_icon;}?>
                                    <span id="caltotal"><?php echo $calvat $itemtotal $servicetotal-($discount $pdiscount);?></span>
                                    <?php if($currency->position==2){echo $currency->curr_icon;}?>
                                </strong></span></label></td>
                              </tr>

I found some result on google, but those are not working.

CodePudding user response:

One of the ways to define decimal value precision is rounding. You can use round($number, $precision)

With your example it would look like so:

round($calvat $itemtotal $servicetotal-($discount $pdiscount), 2);

https://www.php.net/manual/en/function.round.php

  • Related