I am calculating a buyPrice that has a factor of 1.2 times the normal price.
To do this I get the token price and multiply it by 1200000000000000000 (18). It looks something like:
uint256 buyPrice = get18DecimalPrice() * 18DecimalBuyMultiplier;
This works, but it leaves me with a 36 decimal integer. I need it to be 18 decimals for further calculations. How can I slice off the last 18?
I am aware that when you divide a 36 decimal uint with an 18 decimal uint, the result is an 18 decimal uint. I'm just not sure what to do to achieve such a result in this case.
EDIT: Thanks to Paul Razvan Berg I started using PRBMath, which does not produce the same problem. I am still looking for an answer to the question as I am curious about how these math libraries handle the problem laid out in the question.