0

I want to store uint public MINTING_VELOCITY = 0.000002;

And later use it in the formula: A x t x MINTING_VELOCITY ,where A = 2000 ,t(staking_duration_time) = 120

Issue is currently MINTING_VELOCITY is reading 0.

How to take the exact/fetch the decimal value with exact precision?Please follow the code shared in the screenshot to understand the scenario betterenter image description here

How to achieve that via solidity .Please help!

2

1 Answer 1

2

Just use cast to integer arithmetic:

MINTING_VELOCITY = 2
ACCURACY_RATIO = 1000000

And the formula converts to: A x t x MINTING_VELOCITY / ACCURACY_RATIO

2
  • it wont work.Please look into the code snipped that I have just shared.Thanks
    – sauravs24
    Feb 8, 2021 at 9:34
  • it actually helped me partially.Thanks man!
    – sauravs24
    Feb 8, 2021 at 11:17

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.