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?
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?
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.