How to do floating point/decimal math in Solidity
A guide on working with decimals in Solidity
Solidity has no concept of floating point numbers. But you can still do decimal math in Solidity.
The easiest way is to use a library. A commonly used one is ABDKMathQuad.
https://github.com/abdk-consulting/abdk-libraries-solidity/blob/master/ABDKMathQuad.md
(use it at your own risk, this post is for educational purposes only. I have not verified if that package is legit, accurate or safe to use.)
Also see my post on math functions in Solidity and percentages in Solidity code
This post is incomplete and a work-in-progress
I'll update it soon and flesh it out with
more
info!
Spotted a typo or have a suggestion to make this crypto dev article better? Please let me know!
Previous post
π Solidity Auditing online quiz
Learn how to audit smart contracts by looking at some example code and trying to find the bugs
β½ Solidity Gas Optimizations Guide
How to optimize and reduce gas usage in your smart contracts in Solidity
π§ͺ Guide to testing with Foundry
Guide to adding testing for your Solidity contracts, using the Foundry and Forge tools
π Guide to UTXO
UTXO and the UTXO set (used by blockchains such as Bitcoin) explained
π Solidity Assembly Guide
Introduction guide to using assembly in your Solidity smart contracts
π¦ Ethereum EOF format explained
Information explaining what the upcoming Ethereum EOF format is all about