A few days ago, I realized that using abs( can save space!
For example, instead of

Code:
:If X=1 or X=5
use

Code:
:If 2=abs(X-3

and instead of

Code:
:If A>2 and A<10
use

Code:
:If 4>abs(A-6

Very Happy
save space at the cost of speed. My initial reaction is that using abs( the way you describe would be a great slowdown
Another trick to save space: change
N/5
to
5-1N
All abs( does is make the argument positive, though
calc84maniac wrote:
All abs( does is make the argument positive, though


...and you have the subtraction in there, as well. And remember, this is all being done on a 9-byte floating-point number
better yet max(X={2,5,34,25
KermMartian wrote:
Another trick to save space: change
N/5
to
5-1N


How does taht save any space? It's still the same number of tokens.
Not if it's a complex expression (complex as in complicated):
(B-CA)/5
as opposed to
5-1(B-CA

One byte saved.
But it still goes slower.
5-14589
is slower than
(4589)/5

And adding parenthesis goes slower. So the -1 trick is good to save space but not to improve speed.

Also, when doing
fpart(9-1dim(L1
fpart(9-1*9
returns 1
int(9-1*9 returns 0

even if the dim of L1 = 3, there will be an fpart.
Yes, it does indeed go slower. Therefore it's a size optimization, not a speed optimization.
I did some tests today, and the abs( routine is about 17% faster. Very Happy
calc84maniac wrote:
I did some tests today, and the abs( routine is about 17% faster. Very Happy


post the code you used

Code:
:starttmr->S
:For(X,1,10000
:A=1 or A=5
:End
:Disp checktmr(S
:starttmr->S
:For(X,1,10000
:2=abs(A-3
:End
:Disp checktmr(S
calc84maniac wrote:
I did some tests today, and the abs( routine is about 17% faster. Very Happy


17% faster than what?

Code:

:If X=1 or X=5

use

Code:

:If 2=abs(X-3


and instead of

Code:

:If A>2 and A<10

use

Code:

:If 4>abs(A-6


Or

Code:
:If max(X={1,5

?
Ooh, forgot about the max( one. I'll test that out.

Edit: Yay! The abs( routine is about 28% faster than the max( one! Very Happy Very Happy
I discovered that one byte and precisely one millisecond can be saved from:
round(rand,0
instead of
randInt(0,1
Thanks Kerm! Smile I'll use that in my Sudoku program! (84 bytes saved so far! Very Happy )
Heh, good for you. I'm thinking of making a mini-contest of Scrabble AIs to see if someone can come up with a better method than my recursive solver.
  
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 1 of 1
» 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