Search code examples
javascriptmathroundingfractions

Math in JS - How do I get a ratio from a percentage


I'm trying to make a converter, but i don't know the formula to do this, for example, how do I get the ratio of 85694 of 30711152. So, i can get the % like 85694/30711152*100=0.28 (rounded) but how do I then get the ratio of like 1 in a 100? I believe that'd be around 1:400? But i don't know how to get it exactly or what formula to use...


Solution

  • The ratio is 1 in 30711152 / 85694. Just invert the fraction.