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
United-TI Archives -> TI-Basic
 
    » Goto page Previous  1, 2, 3  Next
» View previous topic :: View next topic  
Author Message
DarkerLine
ceci n'est pas une |


Super Elite (Last Title)


Joined: 04 Nov 2003
Posts: 8328

Posted: 14 Jan 2004 05:27:21 pm    Post subject:

what is faster, A=1, not(not(A, or A!=0 ?
Back to top
Adm.Wiggin
aka Tianon


Know-It-All


Joined: 02 Jun 2003
Posts: 1874

Posted: 14 Jan 2004 05:41:33 pm    Post subject:

just plain A would be fastest there.
Back to top
DarkerLine
ceci n'est pas une |


Super Elite (Last Title)


Joined: 04 Nov 2003
Posts: 8328

Posted: 14 Jan 2004 05:52:02 pm    Post subject:

My goal with these is to make the result always be either 0 or 1.
Back to top
Arcane Wizard
`semi-hippie`


Super Elite (Last Title)


Joined: 02 Jun 2003
Posts: 8993

Posted: 15 Jan 2004 06:16:39 am    Post subject:

I'd say test it yourself, just use something like this:

For(X,1,500
If X!=0:Output(1,1,X
End

time it.

For(X,1,500
If not(not(X:Output(1,1,X
End

time that.

etc.

And finally compare the times.

Keep in mind If A, or A combined with any boolean operator will return true or false.

If A
If A AND 1
If A OR 0
etc.

Just thought I'd mention it.


Last edited by Guest on 15 Jan 2004 06:18:18 am; edited 1 time in total
Back to top
sgm


Calc Guru


Joined: 04 Sep 2003
Posts: 1265

Posted: 15 Jan 2004 01:08:17 pm    Post subject:

Arcane Wizard wrote:
For(X,1,500
If X!=0:Output(1,1,X
End

Unfortunately, that will never happen.
Back to top
Arcane Wizard
`semi-hippie`


Super Elite (Last Title)


Joined: 02 Jun 2003
Posts: 8993

Posted: 15 Jan 2004 01:26:07 pm    Post subject:

It's the same as If X, only 2 bytes bigger.
Back to top
Adm.Wiggin
aka Tianon


Know-It-All


Joined: 02 Jun 2003
Posts: 1874

Posted: 15 Jan 2004 06:10:25 pm    Post subject:

actually, it will always happen that way Laughing
Back to top
sgm


Calc Guru


Joined: 04 Sep 2003
Posts: 1265

Posted: 15 Jan 2004 06:48:24 pm    Post subject:

Adm.Wiggin wrote:
actually, it will always happen that way Laughing

No, because there is no integer from 1 to 500 whose factorial is 0.
Back to top
DarkerLine
ceci n'est pas une |


Super Elite (Last Title)


Joined: 04 Nov 2003
Posts: 8328

Posted: 15 Jan 2004 06:53:22 pm    Post subject:

He meant "not equal to" not "factorial equal to".
Back to top
X1011
10100111001


Active Member


Joined: 14 Nov 2003
Posts: 657

Posted: 15 Jan 2004 08:11:39 pm    Post subject:

Wouldn't it be more accurate to just do:

For(X,1,500
not(not(X
End

and

For(X,1,500
X/=0
End
Back to top
Arcane Wizard
`semi-hippie`


Super Elite (Last Title)


Joined: 02 Jun 2003
Posts: 8993

Posted: 16 Jan 2004 10:03:58 am    Post subject:

It would be faster, but it wouldn't be MORE accurate, because you remove an equal amount of calculations on both for loops.

Besides, it's nice to know the value of X so you know when you need to get ready with your stopwatch.
Back to top
Toksyuryel
Crimson Dragon Software


Elite


Joined: 14 Jun 2003
Posts: 880

Posted: 16 Jan 2004 01:34:40 pm    Post subject:

Sir Robin wrote:
He meant "not equal to" not "factorial equal to".

What people need to do is just put an explenation in their post. Because not everyone knows scripting language conventions. But any way, yeah in most scripting languages "!=" means "not equal to".
Back to top
DarkerLine
ceci n'est pas une |


Super Elite (Last Title)


Joined: 04 Nov 2003
Posts: 8328

Posted: 16 Jan 2004 04:14:58 pm    Post subject:

Arcane Wizard wrote:
It would be faster, but it wouldn't be MORE accurate, because you remove an equal amount of calculations on both for loops.

Besides, it's nice to know the value of X so you know when you need to get ready with your stopwatch.


Code:
100 -> X
Pause "Enter to start"
For(I,1,1000
not(not(X
End
Pause "Test 1 finished"
For(I,1,1000
X<>0
End
Pause "Test 2 Finished"
For(I,1,1000
X and 1
End
"Test 3 Finished

This would really be more accurate because X stays constant.
Back to top
X1011
10100111001


Active Member


Joined: 14 Nov 2003
Posts: 657

Posted: 16 Jan 2004 11:33:19 pm    Post subject:

But usually X would be different so it would be more accurate to have it change.

Quote:
It would be faster, but it wouldn't be MORE accurate, because you remove an equal amount of calculations on both for loops.

But if you take out the other part and make it do it more times, there will be more of a difference between them.
Back to top
Arcane Wizard
`semi-hippie`


Super Elite (Last Title)


Joined: 02 Jun 2003
Posts: 8993

Posted: 17 Jan 2004 03:59:57 am    Post subject:

Sir Robin wrote:
This would really be more accurate because X stays constant.

Actually, no, because X will be the same (from 1 to 500) in both situations it does not matter if X is constant or not.

Quote:
But if you take out the other part and make it do it more times, there will be more of a difference between them.
What do you mean?
Back to top
X1011
10100111001


Active Member


Joined: 14 Nov 2003
Posts: 657

Posted: 17 Jan 2004 06:59:37 pm    Post subject:

Quote:
Quote:
But if you take out the other part and make it do it more times, there will be more of a difference between them.
What do you mean?

If you do the If and Output, more % of the time will be spent on doing that, and there will not be as much of a diffrence between the times each of them take.


Last edited by Guest on 17 Jan 2004 07:00:40 pm; edited 1 time in total
Back to top
Arcane Wizard
`semi-hippie`


Super Elite (Last Title)


Joined: 02 Jun 2003
Posts: 8993

Posted: 18 Jan 2004 04:26:24 am    Post subject:

I suppose so, but it still works out relative to each loop.
Back to top
DarkerLine
ceci n'est pas une |


Super Elite (Last Title)


Joined: 04 Nov 2003
Posts: 8328

Posted: 18 Jan 2004 02:13:09 pm    Post subject:

Arcane Wizard wrote:
Actually, no, because X will be the same (from 1 to 500) in both situations it does not matter if X is constant or not.

What if one way works equally well for all X values, and another takes more time the more X is?
Back to top
Arcane Wizard
`semi-hippie`


Super Elite (Last Title)


Joined: 02 Jun 2003
Posts: 8993

Posted: 18 Jan 2004 02:52:59 pm    Post subject:

Then it would still have a constant difference in speed, since the only thing you change between the loops are the boolean operators.
Back to top
DarkerLine
ceci n'est pas une |


Super Elite (Last Title)


Joined: 04 Nov 2003
Posts: 8328

Posted: 18 Jan 2004 02:59:05 pm    Post subject:

Alright. Suppose that one way takes X milliseconds while the other always takes 1 second (actually you might want to divide that by some constant). So in the For(X case, one way would take 500*501/2 = 125250 milliseconds and the other would take only 50000 milliseconds. But if I want to use it for a value between 0 and 94, then the way that took 2.5x more time would actually work best.
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
    » Goto page Previous  1, 2, 3  Next
» View previous topic :: View next topic  
Page 2 of 3 » All times are UTC - 5 Hours

 

Advertisement