Right. This isn't a particularly good solution to the problem, as it will only ever produce fractions with denominators that are factors of 100. If you were going to use this method, you should use a highly composite number. That would still be a hackfix, though, and it wouldn't work for large denominations. You should use an algorithm such as [url=http://tibasicdev.wikidot.com/decimal-to-fraction]the one on tibasicdev[/url instead.
It’s the output commands that’s messing things up. Change the output numbers 3, 5, 6 to 3, 6, 7. The second output command is overwriting part of the first output command.
You'll just have to get the number of digits in each number using log(, and then add that to the X coordinate you use for Output(
commandblockguy wrote:
You'll just have to get the number of digits in each number using log(, and then add that to the X coordinate you use for Output(


Am I taking Log(N), rounding it down, then adding?
This works.


Code:

ClrHome
Input A
iPart(A*100)→A
gcd(A,100)→E
iPart(log(A/E)→H
Output(7,5-H,A/E)
Output(7,6,”/“)
Output(7,7,100/E)
Hang on, back up a bit. I have a couple points to make.
First, on my 84+, I can use >Frac and it works. Although we've established that doesn't work for you, (I guess the world just wants to make your life harder Razz) can you use FRAC? In the mode menu, there's an option "ANSWERS: AUTO DEC FRAC"
Does that work?

Second, some optimizations to your code.
Rather than using multiple Output( commands, use

Code:
Disp "DEGREES: ","RADIANS: π*"
Output(1,10,θ)
Output(2,12,N)


In case you didn't know, in TI-BASIC you don't need to include ) or ending " mosst of the time, I'm only using them because otherwise it doesn't pretty-print my code.
Nomkid

Frac does work, but we couldn’t get it to work in the Output command.
Here you go:


Code:
:ClrHome
:Disp θ,N>Frac
:Output(1,1,"DEGREES:")
:Output(2,1,"RADIANS:")
Nomkid

You have Frac in the Disp command. Try it using the Output command. That’s what we couldn’t get to work.
Dave, I know. That's why I put it in the Disp command. Then it works.
Nomkid wrote:
Hang on, back up a bit. I have a couple points to make.
First, on my 84+, I can use >Frac and it works. Although we've established that doesn't work for you, (I guess the world just wants to make your life harder Razz) can you use FRAC? In the mode menu, there's an option "ANSWERS: AUTO DEC FRAC"
Does that work?

Second, some optimizations to your code.
Rather than using multiple Output( commands, use

Code:
Disp "DEGREES: ","RADIANS: π*"
Output(1,10,θ)
Output(2,12,N)


In case you didn't know, in TI-BASIC you don't need to include ) or ending " mosst of the time, I'm only using them because otherwise it doesn't pretty-print my code.


Is this for memory reduction I take it? I've seen this used before. Also, in regards to the AUTO/DEC/FRAC modes, they don't display fractions through programs. I think I might have to use Disp in this case. my goal was to have stuff outputted all on 1 line ("Radians: " then immediately radians are in line with the string.)
Yes, calcs have limited space, you want to keep them as small as possible.

Also, if you use Disp to display the numbers first, then use Output( to add the titles, it does output all on one line. Just that the numbers are pushed to the right. Try my snippet and you'll see what I mean.
Nomkid wrote:
Yes, calcs have limited space, you want to keep them as small as possible.

Also, if you use Disp to display the numbers first, then use Output( to add the titles, it does output all on one line. Just that the numbers are pushed to the right. Try my snippet and you'll see what I mean.


I understand what you mean. I'll take whatever works at this point lol. Thanks for the help!
Nomkid wrote:
Yes, calcs have limited space, you want to keep them as small as possible.

Also, if you use Disp to display the numbers first, then use Output( to add the titles, it does output all on one line. Just that the numbers are pushed to the right. Try my snippet and you'll see what I mean.


Came up with this:

Code:
Lbl CM
Menu("SELECT","DEG TO RAD",DA,"RAD TO DEG",DB,"BACK",DC)
Lbl DA
Degree
ClrHome
Input "ANGLE: ",θ
ClrHome
θ/180→N
Disp θ,NFrac
Output(1,1,"DEGREES: ")
Output(2,1,"RADIANS: π*")
Radian
Pause
Goto CM
Lbl DB
Radian
ClrHome
Input "RADIANS: ",R
ClrHome
Degree
R°→D
Output(1,1,"RADIANS: ")
Output(1,10,R)
Output(2,1,"DEGREES: ")
Output(2,10,D)
Pause
ClrHome
Goto CM
Lbl DC
Goto Z


Works well, might add some extra text so that there's not a huge gap after the "pi*" string. Is this the only way to get this to render on one line as a reduced fraction though?
Without going down the path you were about to go down, not that I know of.

You could probably figure out a way to determine the length of the string and use Output(2,14-[length] to display it without the gap, but is it really worth it?

Maybe write "RADIANS pi*:" instead if it really bugs you.
Nomkid wrote:
Without going down the path you were about to go down, not that I know of.

You could probably figure out a way to determine the length of the string and use Output(2,14-[length] to display it without the gap, but is it really worth it?

Maybe write "RADIANS pi*:" instead if it really bugs you.


I wanna say the TI-84+CSE has the length function. I’ll find that out later. For now, everything works out pretty well.
  
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
Page 2 of 2
» All times are UTC - 5 Hours
 
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

 

Advertisement