1
function calcPercentage(int elapsedTime){
    return round(8000 + (elapsedTime * (100/36))/10000);
}

user108118
  • 11
  • 1

1 Answers1

0

Solidity does not support floating point math operations. For that, you would need to create your own logic to work on integers and treat a part of them as the whole number and another part of them as the decimals. But that could be combersome.

You can better reuse a library that already solves that, like the prb-math library, abdk-libraries-solidity, etc.

There's a detailed answer that shows many common implementations. Feel free to take a look: What fixed or float point math libraries are available in solidity?

Jeremy Then
  • 4,599
  • 3
  • 5
  • 28