Calculate sell(sales) price from margin and cost price

782 Views Asked by At

Slight finance question, trying to program the calculation of sell price when we have %margin and cost price.

((CostPrice / ((1 - %Margin) / 100)) * 100) / 100

This is what I am doing at the moment. Can someone confirm it is correct. I am having an issue when we do the calculation the other way round so we go with Cost Price and Sell price to get margin the %margin tends to be different and vice versa. Here is the calculation the other way round:

100 * ((SellPrice - CostPrice) / SellPrice)

Is this just a case of decimal places we pass into calculation or is there a way around this?