Discuss Scratch

shmuel3
Scratcher
6 posts

How fast are variables?

I run into this predicament a lot where I have a loop that takes in an input value, does some operation on that value, and it uses that value every loop cycle. the problem is: do I calculate it once, at the beginning, then store it in a variable to prevent it from doing the calculation every cycle, at the expense of keeping track of another temporary variable? Or do I just do the calculation every loop cycle. Thoughts?
-EmeraldThunder-
Scratcher
1000+ posts

How fast are variables?

I would say that it is better to store the calculation in the variable. Especially if it is a long one or involves trigonometric functions.
deck26
Scratcher
1000+ posts

How fast are variables?

It's generally going to be more efficient to calculate something once rather than every time through a loop. Keeping track of variables shouldn't be an issue.
henryforlove
Scratcher
1 post

How fast are variables?

How much days weeks or months will it take for the scratch cloud variables to work again
cosmosaura
Scratch Team
1000+ posts

How fast are variables?

Topic closed due to necroposting.

Powered by DjangoBB