09-07-2017, 06:33 AM

(09-07-2017, 06:26 AM)DerVVulfman Wrote: += Now that's a shortcut. Instead of saying a = a + 1, you say a += 1. So each time we see a value of 'a', we add 1 to it.

-= Another shortcut. Just like above, this one subtracts from the value in question.

< is a 'comparison' operator. It means 'lesser than', and is used in checks like if a < b. If the value of a is 15 and the value of b is 4, then it would be like if 15 is less than 3... Obviously not! That test would FAIL.

And yeah, it is also used for the whole inheritance thing. Pacman here does double duty.

> is another 'comparison' operator. It means 'greater than', and is used in checks like if a > b. So again, if the value of a is 15 and the value of b is 4, then it would be like if 15 is greater than 3... NOW it works! So that IF... block of code will run!

<= and >= respectively mean 'less than or equal to' and 'greater than or equal to' Remember the test of if a < b? If a was set to 5 and b was set to 5, then it would be if 5 was less than 5.... and again, FAIL. But if we did if a <= b, it would work because it was not if a was less than OR EQUAL TO!!!

Equal signs!!! What is different between = and == ? Well, the first replaces the contents of a variable and one does a comparison test.

a = 4 .... this replaces the contents of variable 'a' with the value of '4'

if a == 4 .... this tests if the contents of variable 'a' equals '4'

Oh, the MODULO symbol!!! It means the 'remainder'

%... otherwise the percentage symbol, it is used in programming to get the REMAINDER value of a division. Like... um...

If you divide 9 by 3, your value is 3, right? There's no remainder. It's clean and has nothing fractional. But if you divide 9 by 2, you get 4 1/2 (or 4.5)

NOW unless you tell the program that you are dealing with numbers with decimal values (we call them floats), you're only going to end up with whole numbers. So an INTEGER version of 9 divided by 2 would actually equal 4! That's where modulo comes in... it gets the remainder (or leftover part). So the 9 % 2 would be '1' It can handle dividing 8 by 2, and has a leftover 1 remaining.

EDIT: Was I typing so long??????

OHHHHHH so = equals will convert the 1st thing into the 2nd thing?! while == will see if they're the same!

ok so % is still a tad confusing? its like the smart way to divide?

yeah you type for a LOOONG time lol!

division is done with "/" right?

what does "\" do then?

or != I see that one pop up a few times

new logo for Yesteryear created by Lunarberry!