Fixed point math in Solidity
▻https://hackernoon.com/fixed-point-math-in-solidity-616f4508c6e8?source=rss----3a8144eabfe3---4
It always seems impossible until it’s done. — Nelson MandelaIntroductionAny financial application with a minimum of complexity will need some decimal support and multiplications to calculate things like interest. In the case of CementDAO we needed logarithms to implement the transaction fee curve that steers its cryptocurrency basket towards the desired configuration.Solidity supports integers but no decimals, so we coded a fixed point arithmetic contract, made it safe against overflow, and tested it extensively. It underpins the CementDAO deployment in Ropsten.The Fixidity contract is available from the CementDAO github with a MIT license, please feel free to use it and build upon it.ImplementationIn order to code this we went from the simplest to the most complex arithmetic functions, (...)
#blockchain #mathematics #ethereum #software-development #open-source