I'm sure I read somewhere that Solidity had a fixed point type 'real' of format 32byte.32byte, though the docs say Fixed Point numbers are still to come.
Until it's implemented, is there any best practice or existing library for Fixed Point maths?
Ethereum Stack Exchange is a question and answer site for users of Ethereum, the decentralized application platform and smart contract enabled blockchain. It only takes a minute to sign up.Sign up to join this community
The easiest approach is the one Ethereum itself takes: represent everything in terms of an atomic unit that's smaller than you're likely to need. Ether is represented in Ethereum as 'wei', with 10^18 wei being one ether. All operations being in this unit make the math trivial, and values are divided down when required for display to users.