This is an archived, read-only copy of the United-TI subforum , including posts and topic from May 2003 to April 2012. If you would like to discuss any of the topics in this forum, you can visit Cemetech's TI-BASIC subforum. Some of these topics may also be directly-linked to active Cemetech topics. If you are a Cemetech member with a linked United-TI account, you can link United-TI topics here with your current Cemetech topics.

This forum is locked: you cannot post, reply to, or edit topics. TI-Basic => TI-BASIC
Author Message
Spyderbyte


Advanced Member


Joined: 29 May 2003
Posts: 372

Posted: 07 Jun 2003 11:34:17 pm    Post subject:

Is my calculator being weird, or does the variable end up one higher than the max?

For(A,1,5
End
Disp A

A equals 6. Have I just never noticed this? Neutral

Spyderbyte
Back to top
NETWizz
Byte by bit


Bandwidth Hog


Joined: 20 May 2003
Posts: 2369

Posted: 08 Jun 2003 02:29:10 am    Post subject:

Your calculator is okay.
Back to top
Spyderbyte


Advanced Member


Joined: 29 May 2003
Posts: 372

Posted: 08 Jun 2003 09:01:08 am    Post subject:

Alrighty thanks - I was just wondering.

Spyderbyte
Back to top
Smasher
I'm a llama!


Newbie


Joined: 25 May 2003
Posts: 15

Posted: 09 Jun 2003 12:23:35 am    Post subject:

In case you're interested, here's why that happens. Assuming an example of For(N,1,10), the calculator sets N to 1 and then runs through the loop. For each successive run-through, the calculator increments N, then checks to see if N is less than or equal to 10. Since this condition tests true when N is 10, it will run through the loop, then increment N one more last before checking it, bringing it to 11.

That's probably more info than you needed, but it's nice to know why the calculator does the things it does.
Back to top
Darth Android
DragonOS Dev Team


Bandwidth Hog


Joined: 31 May 2003
Posts: 2104

Posted: 09 Jun 2003 12:53:20 pm    Post subject:

likewise,

Code:
For(N,1,10
N-1->N
End

will never stop repeating
Back to top
NETWizz
Byte by bit


Bandwidth Hog


Joined: 20 May 2003
Posts: 2369

Posted: 09 Jun 2003 03:33:23 pm    Post subject:

N is a floting point real that will eventually become small enough to overflow. Creating err:overflow.
Back to top
Adm.Wiggin
aka Tianon


Know-It-All


Joined: 02 Jun 2003
Posts: 1874

Posted: 09 Jun 2003 03:48:29 pm    Post subject:

maybe... y dont we try it on an emulator? that way, if it crashes, it is still safe!
Back to top
Spyderbyte


Advanced Member


Joined: 29 May 2003
Posts: 372

Posted: 09 Jun 2003 04:16:43 pm    Post subject:

Quote:
In case you're interested, here's why that happens. Assuming an example of For(N,1,10), the calculator sets N to 1 and then runs through the loop. For each successive run-through, the calculator increments N, then checks to see if N is less than or equal to 10. Since this condition tests true when N is 10, it will run through the loop, then increment N one more last before checking it, bringing it to 11.

That's probably more info than you needed, but it's nice to know why the calculator does the things it does.


Yeah I figured out why it does it, I had just never noticed it before.

Spyderbyte

Quote:
N is a floting point real that will eventually become small enough to overflow. Creating err:overflow.


I don't understand what you mean. Doesn't the N-1->N just cancel out the the for loop? I ran it on VTI, and had it increment A each loop, and when I stopped it A was over 16000, and I didn't run into any problems.

Spyderbyte
Back to top
NETWizz
Byte by bit


Bandwidth Hog


Joined: 20 May 2003
Posts: 2369

Posted: 09 Jun 2003 04:37:42 pm    Post subject:

Yeah, good point.

The for loop ads one, and N-1->N subtracts one.

I guess it could run forever or until the batts go dead.
Back to top
Darth Android
DragonOS Dev Team


Bandwidth Hog


Joined: 31 May 2003
Posts: 2104

Posted: 10 Jun 2003 09:59:13 pm    Post subject:

i know bcuz i made the mistake of doing so!
Back to top
Display posts from previous:   
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
    »
» View previous topic :: View next topic  
Page 1 of 1 » All times are UTC - 5 Hours

 

Advertisement