Filling a String
#6

The % operator is called the modulus operator (nothing like the mathematical modulus like |-5| = 5).

It will return the remainder of a division, so if you do:
pawn Код:
20 % 10
It will return 0, because 20 goes into 10 twice, with 0 remainder.

However if you do:
pawn Код:
21 % 10
It will return 1, because 21 can be divided into 10 twice (the 20) and then theres 1 remainder.

The ? and : are triadic operators, so the whole function is basically saying:

"If the return value of 'val % 10' is 0, then return true, if there is any remainder, then return false."

So if you plug a value into that function it will return true if the value is divisible by 10, and return false if its not.

You could also use a macro:

pawn Код:
#define IsDivTen(%1) ((%1) % 10)?(false):(true)
Reply


Messages In This Thread
Filling a String - by Nonameman - 22.08.2010, 20:05
Re: Filling a String - by CJ101 - 22.08.2010, 20:11
Re: Filling a String - by Nonameman - 22.08.2010, 20:14
Re: Filling a String - by pyrodave - 22.08.2010, 20:16
Re: Filling a String - by Nonameman - 22.08.2010, 20:19
Re: Filling a String - by pyrodave - 22.08.2010, 20:29
Re: Filling a String - by Nonameman - 22.08.2010, 21:07

Forum Jump:


Users browsing this thread: 7 Guest(s)