Question by
Temseii · Jan 18, 2018 at 10:22 AM ·
c#programmingmath
Modifying number based on % change
I'm trying to create a price based on the amount of supply available. For example, if we have a stock of 40 million in the commodity with a base price of $20, I need the price to decrease by 0.06% when every 0.125% change upwards in the supply, and to increase by 0.1% every 0.125% change downwards in the supply.
Here is what I have been able to come up with so far...
public void AddDailyCrudeOil() {
CrudeOilSupplyRussia += DailyCrudeOilAmountRussia;
/*
* If DailyCrudeOilAmount is greater than 0.125%, we decrease price by 0.06%
* At our base supply, 40M, 0.125% will be 50K, and the condition will be true as our daily supply delivery is 100k
* */
if (DailyCrudeOilAmountRussia > CrudeOilSupplyRussia * 0.00125f) {
CrudeOilPriceRussia *= -0.0006f;
}
}
But of course, this will only work once and not incrementally.
I've been stuck on this for longer than I'd like to admit, and any guidance is very welcome.
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612150748im_/https://answers.unity.com/themes/thub/images/avi.jpg)