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.
DragonScholar71 wrote:
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.
that would be perfect thank you. the biggest problom is even if i start with a string of a fraction is that i need to manuplate the fraction and if i do that then i no loner have an accurate string. if you could send it that would be great thank you 🙂
CorbinCollins wrote:
that would be perfect thank you. the biggest problom is even if i start with a string of a fraction is that i need to manuplate the fraction and if i do that then i no loner have an accurate string. if you could send it that would be great thank you 🙂
Does it matter if the fraction is simplified? for example if you inputted 2/4 would it matter if it came out as 1/2?
DragonScholar71 wrote:
CorbinCollins wrote:
that would be perfect thank you. the biggest problom is even if i start with a string of a fraction is that i need to manuplate the fraction and if i do that then i no loner have an accurate string. if you could send it that would be great thank you 🙂
Does it matter if the fraction is simplified? for example if you inputted 2/4 would it matter if it came out as 1/2?
no its fine if it comes back simplified
is there a way to seperate a fraction into its two parts like lets say you have 5n/d10->F then how would you get it so that you could do 5->N and 10->D
CorbinCollins wrote:
is there a way to seperate a fraction into its two parts like lets say you have 5n/d10->F then how would you get it so that you could do 5->N and 10->D
That would simplify to 1/2. The issue with isolating fractions is the math always simplifies, since 5/10 is equal to 1/2.
DragonScholar71 wrote:
CorbinCollins wrote:
is there a way to seperate a fraction into its two parts like lets say you have 5n/d10->F then how would you get it so that you could do 5->N and 10->D
That would simplify to 1/2. The issue with isolating fractions is the math always simplifies, since 5/10 is equal to 1/2.
oh ya thats fine i just want to be able to seperate the numerator from the demonater i dont care if its simplfied. i think the way you do it is by multiplieying the decimal approvimation until its a whole number then dividing it by a power of 10 so like 1/2=.5 so you can write it as 5/10 which then would simlfiey to be 1/2
CorbinCollins wrote:
DragonScholar71 wrote:
CorbinCollins wrote:
is there a way to seperate a fraction into its two parts like lets say you have 5n/d10->F then how would you get it so that you could do 5->N and 10->D
That would simplify to 1/2. The issue with isolating fractions is the math always simplifies, since 5/10 is equal to 1/2.
oh ya thats fine i just want to be able to seperate the numerator from the demonater i dont care if its simplfied. i think the way you do it is by multiplieying the decimal approvimation until its a whole number then dividing it by a power of 10 so like 1/2=.5 so you can write it as 5/10 which then would simlfiey to be 1/2
Ok im cooking I think I got it. First compute the final result as a decimal. Then, use a while loop to multiply both the numerator and denominator by 10 until the decimal becomes a whole number, keeping track of how many times this is done. Once the fraction is formed, simplify it by using the GCD( command to find the greatest common divisor, then divide both the numerator and denominator by this value to reduce it to its simplest form. Since Text( doesn’t support fractions properly, the result can be displayed either by manually formatting it with the numerator, a line, and the denominator, or by using the "N/D" format to represent the fraction as text.
CorbinCollins wrote:
CorbinCollins wrote:
DragonScholar71 wrote:
CorbinCollins wrote:
is there a way to seperate a fraction into its two parts like lets say you have 5n/d10->F then how would you get it so that you could do 5->N and 10->D
That would simplify to 1/2. The issue with isolating fractions is the math always simplifies, since 5/10 is equal to 1/2.
oh ya thats fine i just want to be able to seperate the numerator from the demonater i dont care if its simplfied. i think the way you do it is by multiplieying the decimal approvimation until its a whole number then dividing it by a power of 10 so like 1/2=.5 so you can write it as 5/10 which then would simlfiey to be 1/2
Ok im cooking I think I got it. First compute the final result as a decimal. Then, use a while loop to multiply both the numerator and denominator by 10 until the decimal becomes a whole number, keeping track of how many times this is done. Once the fraction is formed, simplify it by using the GCD( command to find the greatest common divisor, then divide both the numerator and denominator by this value to reduce it to its simplest form. Since Text( doesn’t support fractions properly, the result can be displayed either by manually formatting it with the numerator, a line, and the denominator, or by using the "N/D" format to represent the fraction as text.
ok so now i need to figure out how to get the decimal apporximation of the fraction if i use the >Dec notation then i get an error im thinking i can turn it into a string and then convert it back to a number
CorbinCollins wrote:
ok so now i need to figure out how to get the decimal apporximation of the fraction if i use the >Dec notation then i get an error im thinking i can turn it into a string and then convert it back to a number
The ">DEC" Command can only be used in display commands such as "Disp " and "Output(".
The best way I can think of doing it is in the following order:
1. Identify if you are converting to a fraction.
2. Isolate either the top or bottom of the fraction.
3. Calculate the other side respectively.
4. Convert each number into a string independently.
5. Format the numbers into one string or display them as needed.
P.S. these steps were made on the spot so they may need revision.
DragonScholar71 wrote:
CorbinCollins wrote:
ok so now i need to figure out how to get the decimal apporximation of the fraction if i use the >Dec notation then i get an error im thinking i can turn it into a string and then convert it back to a number
The ">DEC" Command can only be used in display commands such as "Disp " and "Output(".
The best way I can think of doing it is in the following order:
1. Identify if you are converting to a fraction.
2. Isolate either the top or bottom of the fraction.
3. Calculate the other side respectively.
4. Convert each number into a string independently.
5. Format the numbers into one string or display them as needed.
P.S. these steps were made on the spot so they may need revision.
ive made a program to turn a frac to variables but it dosent work for repeating numbers greater than 1 like .3636363636
Code:
N->Z
prgmSTR
expr(Str0)->N
N->P
While iPart(N)!=N and I!=10
10*N->N
I+1->I
End
If iPart(N)!=N
Then
int(P*10)->N
9->D
Else
10^I->D
End
gcd(N,D)->G
N/G->N
D/G->D
CorbinCollins wrote:
DragonScholar71 wrote:
CorbinCollins wrote:
ok so now i need to figure out how to get the decimal apporximation of the fraction if i use the >Dec notation then i get an error im thinking i can turn it into a string and then convert it back to a number
The ">DEC" Command can only be used in display commands such as "Disp " and "Output(".
The best way I can think of doing it is in the following order:
1. Identify if you are converting to a fraction.
2. Isolate either the top or bottom of the fraction.
3. Calculate the other side respectively.
4. Convert each number into a string independently.
5. Format the numbers into one string or display them as needed.
P.S. these steps were made on the spot so they may need revision.
ive made a program to turn a frac to variables but it dosent work for repeating numbers greater than 1 like .3636363636
Heres the code
N->Z
prgmSTR
expr(Str0)->N
N->P
While iPart(N)!=N and I!=10
10*N->N
I+1->I
End
If iPart(N)!=N
Then
int(P*10)->N
9->D
Else
10^I->D
End
gcd(N,D)->G
N/G->N
D/G->D
i think i should just call it ive been working on this quadratic formula calulator for almost a year now and ive made almost no progress everywhere i go just see another dead end at this points its the stupid fractions cause the above code dosent work with negtive fractions, with most repeting decimal, or numbers like 1.416666 or .166666 ☹️ i just dont think this is gonna work
CorbinCollins wrote:
i think i should just call it ive been working on this quadratic formula calulator for almost a year now and ive made almost no progress everywhere i go just see another dead end at this points its the stupid fractions cause the above code dosent work with negtive fractions, with most repeting decimal, or numbers like 1.416666 or .166666 ☹️ i just dont think this is gonna work
I did not know this was for a Quadratic Formula, there are probably other ways of calculating it than turning the decimal into a fraction. You could find a way to manipulate the actual formula so it gives the two halves independently.
DragonScholar71 wrote:
CorbinCollins wrote:
i think i should just call it ive been working on this quadratic formula calulator for almost a year now and ive made almost no progress everywhere i go just see another dead end at this points its the stupid fractions cause the above code dosent work with negtive fractions, with most repeting decimal, or numbers like 1.416666 or .166666 ☹️ i just dont think this is gonna work
I did not know this was for a Quadratic Formula, there are probably other ways of calculating it than turning the decimal into a fraction. You could find a way to manipulate the actual formula so it gives the two halves independently.
i dont think so because by using the built in fraction stuff it can do all the math for me and all i need to do is sepetrate the values. im think a better way would be to do multiply the fraction by a for loop until it equals one and then divide that number by another for loop until it equals the same as the orginal fraction. but i think my quad is good enough rn it has a few bugs its not that great but its still better than most on here and its not that bad. i just need to do some final bug testing. Then create the read me stuff and upload it.
CorbinCollins wrote:
i dont think so because by using the built in fraction stuff it can do all the math for me and all i need to do is sepetrate the values. im think a better way would be to do multiply the fraction by a for loop until it equals one and then divide that number by another for loop until it equals the same as the orginal fraction. but i think my quad is good enough rn it has a few bugs its not that great but its still better than most on here and its not that bad. i just need to do some final bug testing. Then create the read me stuff and upload it.
Well I don't know the goal of the code so there isn't much I can do. If you really are stumped you can send me the code and I can try to help, but if not then good luck.
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