22.08.2010, 20:29
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:
It will return 0, because 20 goes into 10 twice, with 0 remainder.
However if you do:
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:
It will return the remainder of a division, so if you do:
pawn Код:
20 % 10
However if you do:
pawn Код:
21 % 10
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)