0
Considering the following data:
$despesas = 2000;
$receitas = 100;
$lucroprejuizo = ($receitas - $despesas) / $receitas)*100;
I have a result of: -1900%
But if any of the variable revenues or expenses is zero the wrong calculation because it is dividing by zero. Is there any way to calculate?
For example if you consider that I had 0,00
of revenue and 300,00
of expenses he will have -100% profiteering.
It is incorrect to say that you had 100% prejudice to a value ranging from 0 to 300 (and negative loss, so, not even talk). The problem is not in mathematics, but in concepts. I would suggest rethinking logic, based on the practical use of information, first of all.
– Bacco
I agree with @Bacco, logic needs to be rethought. In addition to what he said, also note that if you have a value of 100 receipts and 50 expenses, your $lucroprejuizo variable will give you 50% profit, when in fact the profit is 100%.
– monosan
Thank you all. @monosan some suggestion so in this your example to return me the correct profit?
– Marcos A. Silva
Yes, @mcasite. Split by expenses instead of split by revenues.
– monosan
@monosan and yet, it gets complicated. Profit is absolute, not relative. If I have 200 of expense and 300 of revenue, or if I have 400 of expense and 500 of revenue, the profit is the same, but the percentage changes It may even be that the author wants a "profit on the movement", but there is a good chance that is not what someone will need in practice..
– Bacco
@Bacco, it is, the correct terminology I do not know what it is. But he wants the value in percentage, be it profit or whatever the most appropriate name.
– monosan
@monosan I have my doubts if what he asked for is in fact what he wants, which way, if that’s it, the epx response solves. I just think it’s important for the author to be aware of the problem (and we’ve done this, now it’s up to him).
– Bacco