for converting decimals to fractions? For instance, some way in VB6 I could convert something like .678584 to the most simplified fraction? If there is, how many places past the decimal point is this reliable? Thanks.
Printable View
for converting decimals to fractions? For instance, some way in VB6 I could convert something like .678584 to the most simplified fraction? If there is, how many places past the decimal point is this reliable? Thanks.
Will you need a method for repeating decimals, ie .765765765765...?
If Not, if they always terminate, then multiply it by (10^n) to get a whole integral value.
Then find the GCD between it and 10^n. Divide both by this GCD.
You'll end up with a usable set of (numerator, denominator) for your fraction.
:wave:
sounds good, i'll try to work it out in code and come back if I have any problem. Thanks.
If you do have a repeating decimal type, then, by example, this is how you'd deal with it:
Say you had .1234123412341234...
Thus:
X=.12341234...
10000X=1234.12341234...
10000X-X=1234.12341234... - .12341234....
9999X=1234
X=(1234/9999)
So, now just reduce the fraction .
:wave: