| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|||
|
ok, larkins
I'll try my best to do it. If it doesn't work, my best source for the info is Wikipedia.
So, you take you fraction. We'll do 1/19 as an example. Now, discard the 9. That's not important. Then, add one to whatever else is in the denominator. Hence the name "by one more than the one before". In this case, we get 2. Here's the tricky part. You take the numerator and divide by that number. If there is a remainder, it carries. More on that later. Now what we have is the start of our decimal: 1/2= 0 remainder 1 decimal= .0 (for now) The next "numerator" in the sequence is 10*remainder + quotient, in this case, 10. 10/2= 5 remainder 0 decimal= .05 Now we continue, and don't forget the remainders. 5/2= 2 remainder 1 decimal= .052 12/2= 6 remainder 0 decimal= .0526 =.05263 =.052631 =.0526315 =.05263157 does it check? yes. 1/19=.05263157 this algorithm could definitely be used for fractions, in my opinion. There's also some calculus thing for any number 1/x, but it's slow and recursive, and I don't know it very well. |
|
|||
|
Quote:
you multiply by a fraction equivalent to 1, in this case 7/7. That would make the fraction 14/49, which works. I tried a program using this last night. It didn't work for most things. I think the problem was in predicting the denominator. I can't post the source on here, it's just a bit too long for me. But basically what I did was split the digits up into a list. Then I looked at the last two digits and found some possible ratios between them. (This is probably the problem, because I also have to guess a carry amount, and test it with the other decimals) I go from right to left, trying the different ratios and carry values. I like to compare it to finding a regression line, of sorts. Very much a stat program. But not working. As for Jag's program... I've seen it work, and it's beautiful. I love the Stringverter. But it uses strings, and I want to figure out a mathematical way. It's not hard for most fractions... it's those ones like 1/6 and 16/19 that'll kill you. I'm going back to my programming hole. Goodbye, all. I hope I see you again with my working fraction program. ![]() |
|
|||
|
more answer
Sorry, Larkins. I didn't read your question very carefully. When the denominator is a single digit, like 2/9, you can put a "0" in front of the nine.
0+1=1, and it works. 2/1=2 remainder 0 decimal=.2 etc... decimal=.222222222 |
|
||||
|
And now for the juicy stuff.
The program essentially multiplies the original decimal by increasing powers of 10 until the decimal times the power of ten subtracted by the original decimal is no longer a repeating decimal. Code:
Input N N->Z //just to have a second variable For(B,1,20 //In this case, 20 is arbitrary, it could be any number, the program stops looking for repeaters after 20 digits. N10^(B)-N->Z prgmZSTRVERT //turning the decimal multiplied by the power of ten and subtracted by itself into Str7 length(Str7->L If L<15 //check to see if it is still an infinadecimal Then B->A 20->B //ends the 'for' command End End L-inString(Str7,"."->L //actual number of digits in the fPart (10^(A)-1)10^(L->B //this finds the denominator Z10^(L->A //this is the numerator If A=1 //for some reason, it was unable to find the gcd of 1 and 90, so I just created a bridge if it met that situation Then 1->L Goto A2 End gcd(A,B->L Lbl A2 A/L->Z prgmZSTRVERT Str7->Str1 prgmZSTRVERT Str7->Str2 That's it, the rest is pretty self explanatory... After reading many things, I found out you are a math teacher. That is really cool. I want to do that when I grow up...I'm in classes that you teach... My teacher was pretty proud of me when I wrote this bad boy. It pretty much puts the TI's fraction converter to shame. It needs a little work with what to do if the number is unable to be fractionalized (i.e. pi, root 2 e.g. irrationals) but other than that it is nifty. I need to assembly it and see if I can't squeeze TI out of some money for staying quiet... |
|
||||
|
Quote:
All that I need is a mathamatical way to calculate the length of the decimal. The most efficient way to perform this is by using strings...I don't exactly see it as "un mathematical," unless the way a real human being turns a decimal into a fraction is "un-mathematical"... |
![]() |
| Viewing: Dev Hardware Forums > SOFTWARE > TI 83/84 > How to use Output to display value in fraction |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|