Discuss Scratch

random-buildblocks
Scratcher
49 posts

What does the mod block do?

None of my projects have the mod block because it wasn't important. How do i even use it? You will tell me to use scratch wiki but its too complicated i want short explanation

When i do:
((9) mod (3))

The answer is 0 but when:
((9) mod (10))

Answer is 0?! can you help me?

Last edited by random-buildblocks (June 18, 2022 18:45:58)

musicROCKS013
Scratcher
1000+ posts

What does the mod block do?

It basically divides the first number by the second number and reports the remainder. For example

5 and 2
5-2-2=1

9 and 10
9-10=0 or no remainder

same with 9 and 3

9-3-3-3= there is no remainder

random-buildblocks
Scratcher
49 posts

What does the mod block do?

random-buildblocks wrote:

None of my projects have the mod block because it wasn't important. How do i even use it? You will tell me to use scratch wiki but its too complicated i want short explanation

When i do:
((9) mod (3))

The answer is 0 but when:
((9) mod (10))

Answer is 0?! can you help me?
Wait it was 9 not 0 dfor 2nd
musicROCKS013
Scratcher
1000+ posts

What does the mod block do?

random-buildblocks wrote:

Wait it was 9 not 0 dfor 2nd
..?

The mod block basically gets the remainder. Do you know what that is?
TR_Borg
Scratcher
82 posts

What does the mod block do?

9 mod 10 gives the answer 9, not 0.

When dividing two numbers, the result is the quotient, and the leftover amount is the remainder. The mod operator gives the remainder as its answer.

9 / 3 = 3, remainder 0

So, 9 mod 3 = 0

9 / 2 = 4, remainder 1

So, 9 mod 2 = 1

9 / 10 = 0, remainder 9

So, 9 mod 10 = 9
hedgehog_blue
Scratcher
1000+ posts

What does the mod block do?

musicROCKS013 wrote:

random-buildblocks wrote:

Wait it was 9 not 0 dfor 2nd
..?

The mod block basically gets the remainder. Do you know what that is?
They're saying that the output they were actually getting for 9 mod 10 was 9, which makes sense, not 0, as they were confused by before.

Perhaps your post added to that confusion because you said that the false output of 0 was correct:

musicROCKS013 wrote:

9 and 10
9-10=0 or no remainder
quandlingling
Scratcher
1 post

What does the mod block do?

h

Last edited by quandlingling (Feb. 21, 2025 19:51:19)

Powered by DjangoBB