changing interger with percent sign
#1

Hello,

I saw some lines in a script and I tried everything to understand it (looked in samp wiki, without any results), used ****** and at the end I kept changing the values to figure out a pattern, but it was hopeless..
I can't figure out what this "%" DOES or means:

Код:
new newstatus = 1;

	newstatus %= 2;
	if(newstatus == 0)strcat(newname, "test");
Can someone please explain this? What is it and what is it used for?
Reply
#2

4 % 2 = 0
5 % 2 = 1
19 % 2 = 1

It returns the value that remains after division (19%2; 18 + [1]; [x] => you get returned that X value)

- Just search for Modulo in any search engine; you will find some interesting stuff:

Код:
(in number theory) with respect to or using a modulus of a specified number. Two numbers are congruent modulo a given number if they give the same remainder when divided by that number.
Reply
#3

ahhhh I get it now thank you very much
Where do you get to know such kind of things? If i wouldn't have asked I would have never known
Reply
#4

G o o g l e is your friend.

Just tried "variable %= 2" in the G o o g l e search-bar and the first page was this one:
https://www.w3schools.com/js/js_operators.asp

Further down, there was the % operator, which means modulus.
And a little further down, it lists this in a table:
%= | x %= y | x = x % y

Search G o o g l e for "modulus" and you'll find countless pages which explain it all.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)