# calculate a percentage (dec) difference based on two numbers

I wrote this function a while ago, but im not actually sure what its suppost to do, so ill test it here and see what it returns.

I think after running this function it returns the differents in percentage from the numbers where you provide the total amount and then the difference.

So if the total is 100 and the difference is 20 the result is **80%**

Total is 100 and difference is 1 then the result is **99%**

You can put in massive numbers, not sure if this would be useful like if you want to know the percentage difference between 14567732 and 1495653

Maybe i have called this function the wrong thing, as it takes the difference and then returns the difference as a percentage.

## PHP

```
function calc_percentage_dec($total, $diff) {
$dec = $total - $diff;
return $dec_percent = ( $dec / $total ) * 100;
}
```

## Some randomly generated calculations to try:

### Random Calculation One

Total: 548, Difference: 29### Random Calculation Two

Total: 61696, Difference: 5670Result