I’m trying to turn decimals into fractions so that I can show the fraction in a label. Something like this, but you can see that it doesn’t always work…
Hi! Here is one approach: Convert Decimal to Fraction
Depending on what kind of input you are expecting, a different approach might be better. For example, this approach works well if (1) the denominator of the fraction is at most 1000, and (2) the input is accurate to at least 6 places past the decimal point. If you anticipate larger denominators or less accurate inputs, other approaches might be better.
Thank You! Very helpful. This is a good solution for my use case.