-3

i need to round off up-to 2 decimal,currently i getting 12% but the actual discount is 11.76

my code as follow

$perc=0;
        if($value->IsOfferItem){
          $perc=round(100-(($value->SellingPrice/$value->ActualPrice)*100));
        }
Sijo
  • 7
  • 4

1 Answers1

0

Here's an example

$table->decimal('amount', 5, 2);

In above example first parameter is the field name. Second, parameter is the total length. Third, parameter is the float value.

the table field, for example in mysql must contain decimal (10.2), example:

amount dcecimal(10,2) not null

The 2 indicates decimal places.

The 10 indicates the maximum numerical quantity before the comma.