Does Solidity supports floating point number

10,054

Solution 1

There is no floating point in Solidity. You should keep numbers in whole number format.

You can place decimal place in your front-end code. Take a look at how ERC20 contract was designed.

Good read: https://medium.com/@jgm.orinoco/understanding-erc-20-token-contracts-a809a7310aa5

Solution 2

There is no native support for floating-point numbers in the core language, but they are available via libraries, such as ABDKMathQuad.

Share:
10,054

Related videos on Youtube

Anijit Sau
Author by

Anijit Sau

Love JavaScript

Updated on June 04, 2022

Comments

  • Anijit Sau
    Anijit Sau almost 2 years

    I am new in solidity language. Have seen their documentation. Is there any floating point data type ?

  • Pro Q
    Pro Q over 2 years
    Unfortunately the library you link to looks like it's under copyright, so it cannot be used.
  • Agna JirKon Rx
    Agna JirKon Rx over 2 years
    @Pro Q - true fact