03-03-2004, 06:38 AM
The simplest way to do it is find the GCD of the degrees and 180.
In QB it would be something like
There are ways to convert decimals to fractions, but repeating decimals are handled differently than terminating decimals. You would have to come up with an algorithm to recognise repeating decimals, then handle them appropriately. Examples:
In QB it would be something like
Code:
Divisor = GCD( Degrees, 180)
Numerator = Degrees / Divisor
Denominator = 180 / Divisor
Print Numerator; "/"; Divisor; "Pi"
There are ways to convert decimals to fractions, but repeating decimals are handled differently than terminating decimals. You would have to come up with an algorithm to recognise repeating decimals, then handle them appropriately. Examples:
Code:
' Use the same number of 9's as digits in the pattern
0.3333... = 3/9 ' Repeats one digit. Use one 9.
= 1/3
0.142857142857... = 142857/999999 ' Repeats six digits. Use six 9's.
= 1/7
' If there is a non-repeating part it has to be handled separately as a terminating decimal,
' and zeros (the same number as the non-repeating part) added after the nines
2.35142857142857... = 2.35 + 0.00142857142857...
= 235/100 + 142857/99999900
= 235/100 + 1/700
= 1645/700 + 1/700
= 1646/700
= 823/350
hrist Jesus came into the world to save sinners, of whom I am first.(I Timothy 1:15)
For God so loved the world, that He gave His only begotten Son,
that whoever believes in Him should not perish, but have eternal life.(John 3:16)
For God so loved the world, that He gave His only begotten Son,
that whoever believes in Him should not perish, but have eternal life.(John 3:16)