Here's a simplistic approach, but you should be able to use it as a starting point. Decimal values are, by definition, base ten; I don't think you'll ever get 2/3 from .66667 using a mathematical approach. Here goes...
Starting with
.66667 1.5 .8
Use 10 as the common denominator. Multiply the decimal portion by 10.
6.6667 5 8
Take the integer value. This will be your numerator.
6 5 8
Your ratios are
6/10 5/10 8/10
Resolve to the lowest ratio.
If MOD(numerator,5)=0 --divisible by 5
numerator = numerator / 5
AND denominator = denominator / 5
ELSE If MOD(numerator,2)=0 --divisible by 2
numerator = numerator / 2
AND denominator = denominator / 2
3/5 1/2 4/5
If there was an integer portion, multiply it by the denominator and add that to the numerator.
3/5 3/2 4/5
Now my brain hurts. I need a Mountain Dew. Good luck!
--Angel
![[rainbow] [rainbow] [rainbow]](/data/assets/smilies/rainbow.gif)
-----------------------------------
Every time I lose my mind, I wonder
if it's really worth finding.