im using a ti 84 plus calculator on ti basic
the code for converting a int into a string is
{0,1→L₁
:NAns→L₂
:LinReg(ax+b) Y₁
:Equ►String(Y₁,Str1
:sub(Str1,1,length(Str1)-3→Str1
the problom is that if n is a fraction then it will convert the fraction to a decimal at after Equ►String(Y₁,Str1) but i want it to remain a fraction
is there any way to turn a fraction into a string?
It looks like you're making use of the old 83-series number-to-string routine. If you're not on a CE, then this routine is all you have; you'll need to convert the numerator and denominator separately and combine them.
If you are on a CE, though, then toString( gets the job done for fractions and a whole lot else.
oh sorry im using a ti-84 plus calculator in ti basic
kg583 wrote:
It looks like you're making use of the old 83-series number-to-string routine. If you're not on a CE, then this routine is all you have; you'll need to convert the numerator and denominator separately and combine them.
If you are on a CE, though, then toString( gets the job done for fractions and a whole lot else.
how do i separate the numerator and the denominator
im storing the built in fraction to not turn into a decimal (so the alpha y= or f1 on the calc) into my variable
wasupyo7890 wrote:
also if this is on a calculator I would suggest letting it convert into decimial for the calculations because it honestly just makes calculations easier for the calculator to have a decimal value especially in mathmatical programs
ive considered doing that but the problem is that in general decimals arnt accepted because there not precise and usually a decimal will be to big and take up to much space pushing everything else off screen
Edit by Admin: Combined posts
Could you use a string input instead of a number input? You're creating the value through the Alpha+F1 menu, so I'm assuming you could instead do something like:
Code: "5/6->Str1
inString(Str1,"/->A
If A:Then
sub(Str1,1,A-1->Str2
sub(Str1,A+1,length(Str1)-A->Str3
End
Then Str2 and Str3 hold the numerator and denominator. Or you can use expr( to get real values:
Code: "5/6->Str1
inString(Str1,"/->A
If A:Then
expr(sub(Str1,1,A-1->N
expr(sub(Str1,A+1,length(Str1)-A->D
End
Then N and D have your numerator and denominator. You can also do expr(Str1 to get the real value if you need to then do math on it and >Frac it from there. If you need to then take the results of that math and get a string, you would then be in the same position, though.
merthsoft wrote:
Could you use a string input instead of a number input? You're creating the value through the Alpha+F1 menu, so I'm assuming you could instead do something like:
Code: "5/6->Str1
inString(Str1,"/->A
If A:Then
sub(Str1,1,A-1->Str2
sub(Str1,A+1,length(Str1)-A->Str3
End
Then Str2 and Str3 hold the numerator and denominator. Or you can use expr( to get real values:
Code: "5/6->Str1
inString(Str1,"/->A
If A:Then
expr(sub(Str1,1,A-1->N
expr(sub(Str1,A+1,length(Str1)-A->D
End
Then N and D have your numerator and denominator. You can also do expr(Str1 to get the real value if you need to then do math on it and >Frac it from there. If you need to then take the results of that math and get a string, you would then be in the same position, though.
i might have to just do that if there's no other way but would this work if the denominator the numerator are bigger than 9 ie if you have a fraction that is 1506/45043 than would that still work
here some added context if it helps im using this for a quadratic equation caulculator first it ask you for the value of a then b then c and then it does the quadratic euqaiton to return the values for x but its not accepted if you just give decimal approximation plus it would be nice if could work with fractions sense there easier for some of the other math stuff i need to do
I am making my own updated version of the Number to String code, I should have it posted here soon.
the input is changed from a variable to a list (I'll list instructions with the code.) It takes the decimal value and finds the two values of the fraction. I have not tested it with many fractions so I cannot guarantee too much reliability, but I do know it works. I just need to copy it onto the sourcecoder so I have it readily available.
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.
»
Go to Registration page
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum