learn-gdscript icon indicating copy to clipboard operation
learn-gdscript copied to clipboard

Lesson 15

Open DexLovesGames opened this issue 3 years ago • 0 comments

<Read the edit at the bottom, please.>

Notice how the modulo can be larger than the number it affects. For example, 1 % 2 gives you 1. That's because 1 divided by 2 equals 0, and the remainder is 1.

1 divided by 2 equals 0

1 / 2 = 0

What? This doesn't make any sense. 1 divided by 2 equals 0.5, not 0, so how does the remainder end up being 1, shouldn't the remainder be 0.5 as well? This needs better explanation.

image

EDIT: Okay So I am dumb, and forgot how division without decimals works, but I still feel like better explanation of this would be helpful. I realize now that 3 / 2 = 1 with a remainder of 1, and the remainder is all that 3%2 is looking for, and if I apply the same logic to 1/2 then 2 goes into 1 0 times, with 1 being the integer left over as remainder. Basic math, and here I'm trying to look at it from college level algebra lol.

DexLovesGames avatar Jun 29 '22 00:06 DexLovesGames