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!

sauravs24
  • 33
  • 4

1 Answers1

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

Mad Jackal
  • 1,195
  • 2
  • 5
  • 8