Discuss Scratch

A_game_Programmer
Scratcher
8 posts

Optimising division

I am coding a triangle filler, and am wondering if there is a way to get scratch to not calculate the decimals.
E.g. 5 / 3 = 1.666666667, is there a way to tell scratch to stop the calculation when it reaches the decimals so that it spends less time on the calculation
I know that there is floor ( ), but scratch will still calculate the division first before chopping off the decimals which is not what I want as it still loops through the calculation of all decimal points.
If there is not any way to do then it is fine, I will try to do something with ( ) mod ( )
Igor-Gaming
Scratcher
71 posts

Optimising division

I'm not sure if this will be faster but you can make a counter go up until it's score is equal to letter (x) of the number. In this case the (x) would represent the letter number of the period.

Welcome to the Velvet Room
Yusei-Fudo
Scratcher
1000+ posts

Optimising division

So you want Scratch to calculate, but stop when it hits any decimals (That's not possible unless you change how Scratch calculates)?

Not too sure if that's going to make anything faster, but you could try using this block:
(() mod ())// If it reports a 0, then that number has no remainder, if it's other than 0, it has a remainder.

So you could try this:
if <(() mod ()) = [0]> then
calculate
end

Last edited by Yusei-Fudo (May 20, 2021 03:14:38)


I'm a decent coder who has a huge passion for coding. I taught myself all the coding skills I have now. And with those skills, I have made some pretty decent projects, check them out! Be sure to ⭐ ❤️ & Follow, too! I have a few pictures below which are actually links. Click on them to take to different projects that I made. Might come in handy. :)

Need a project where you can check to see if you can use someone's camera or not? Here's one:


Need a project to detect when someone has clicked the stop sign? Take a look at this:

Need a project that can point at specific clones, etc? Why not use this:


Need to prank someone? Tell them to click this picture, but also make sure they're signed onto Scratch, otherwise, it doesn't work:


For more of my projects, just click on this picture:
UltraGamer_Studios
Scratcher
96 posts

Optimising division

Scratch doesn't have any integer division. Your best bet is just to use floor(), which doesn't make it any faster. Division can be done extremely quickly on a computer so I think you'll be fine just using floor().

Yusei-Fudo
Scratcher
1000+ posts

Optimising division

UltraGamer_Studios wrote:

Scratch doesn't have any integer division. Your best bet is just to use floor(), which doesn't make it any faster. Division can be done extremely quickly on a computer so I think you'll be fine just using floor().
true

I'm a decent coder who has a huge passion for coding. I taught myself all the coding skills I have now. And with those skills, I have made some pretty decent projects, check them out! Be sure to ⭐ ❤️ & Follow, too! I have a few pictures below which are actually links. Click on them to take to different projects that I made. Might come in handy. :)

Need a project where you can check to see if you can use someone's camera or not? Here's one:


Need a project to detect when someone has clicked the stop sign? Take a look at this:

Need a project that can point at specific clones, etc? Why not use this:


Need to prank someone? Tell them to click this picture, but also make sure they're signed onto Scratch, otherwise, it doesn't work:


For more of my projects, just click on this picture:

Powered by DjangoBB