- Home
·
- Math/Dates
·
- Converts a decimal to a fraction, including repeating decimals like .333333... or decimals like .47
Converts a decimal to a fraction, including repeating decimals like .333333... or decimals like .47
Converts a decimal to a fraction, including repeating decimals like .333333... or decimals like .4726211111... Also converts 4.56666... and
Rate Converts a decimal to a fraction, including repeating decimals like .333333... or decimals like .47
(2(2 Vote))
'None of the variables should contain a decimal in them. A good example of this
'is: mystring$ = Math_DecFrac(4, 3452, 7) - will convert 4.3452777777... into a
'fraction. The answer is 391075/90000.
thefirst$ = Trim(Str(nonrepeating) + Trim(Str(repeating)))
thesecond = 10 ^ (Len(thefirst$))
thethird = 10 ^ (Len(nonrepeating))
MathFrac = Trim(Str((Val(thefirst$) - nonrepeating))) + "/" + Trim(Str((thesecond - thethird)))
wholenumber = wholenumber * Val(Trim(Str((thesecond - thethird))))
thetop = Val(Trim(Str((Val(thefirst$) - nonrepeating)))) + Val(wholenumber)
thebottom = Trim(Str((thesecond - thethird)))
Math_DecFrac = Trim(Str(thetop)) + "/" + Trim(Str(thebottom))
End Function
Converts a decimal to a fraction, including repeating decimals like .333333... or decimals like .47 Comments
No comments yet — be the first to post one!
Post a Comment