Percentage calculation

Asked

Viewed 78 times

-3

In my online store I have the following option ex: of 1,119,00 by 999,00 the current price and the discount price, how can I know how many percent the person is saving with the purchase ? type how many percent discount the purchase has ? using the old value field and new value, hug

1 answer

1

I use it as follows:

(V2-V1)/V1 × 100 = PORCENTAGEM

Let’s say you have an item that has the value of R $ 50 and with the discount was R $ 20 so we put as follows:

((20 – 50)/50) × 100 = PORCENTAGEM

(-30/50) × 100 = PORCENTAGEM

-0,60 × 100 = -60%

In PHP:

$valorAntigo = 50;
$valorNovo   = 20;

$Porcentagem = (($valorNovo - $valorAntigo)/$valorAntigo)*100;

Browser other questions tagged

You are not signed in. Login or sign up in order to post.