hi folks i'm looking do do the following division function here is an example of the input.

_value / (totalSupply() / _shareSupply);

50000000000000000000 / 110000000000000000000 / 100000000000000000000

closed as unclear what you're asking by user19510, goodvibration, Richard Horrocks, Shawn Tabrizi, Rosco Kalis Jan 9 at 10:14

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 2
    Did you have a question? – user19510 Jan 9 at 6:00
  • 1
    There is no clear question in this post – Webdev Jan 9 at 7:32

Some things you should take into account when doing this:

  • Solidity doesn't at the moment have support for floating point arithmetic, so expect rounding
  • There may be other ways of achieving the same outcome
  • Where possible, try and turn division into multiplication, so that you are not affected by rounding errors

If you have to arrive at this ratio, I would propose the following formula:

_value * _shareSupply / totalSupply().

However, if you are, for example checking if this value is greater than some value x, it's better achieved like so:

_value * _shareSupply > x * totalSupply()

Do keep potential overflow risks in mind depending on the maximum size of numbers.

Not the answer you're looking for? Browse other questions tagged or ask your own question.