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?


1 Answer 1


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.

  • Yeah I can understand that. Just trying to gauge the direction of development and future proof a bit if needed. I'm also confusing myself a bit with the fixed point stuff. With a background in micro controller (to which ethereum bares more than a passing resemblance sans shift left/right ops), I'm use to thinking in base 2 fixed point and not based 10 to which I'm realising the luxury of a 256bit word! But no matter, I'll just go with an arbitrary base 10 scaling factor.
    – o0ragman0o
    May 31, 2016 at 11:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.