what does % do in javascript -



what does % do in javascript -

this question has reply here:

what % in javascript? 6 answers

i'm trying convert javascript code java not know % character between 2 numeric variables does:

testvalue= somevalue%anothervalue;

what mean or same statement in java?

i have in javascript

if(somevalue%2==1){ }

what %2 mean here?

it's modulus operator. returns "the first operand modulo sec operand", remainder when substract (or add) much of sec operand off/to of first, close possible 0.

for example:

5 % 2 == 1 ( 5 = 2*2 +1) 6 % 2 == 0 ( 6 = 2*3 +0) 1 % 5 == 2 ( 12 = 5*2 +2) -5 % 2 == -1 (-5 = 2*-2 -1) -6 % 2 == 0 (-6 = 2*-3 -0) -12 % 5 == -2 (-12 = 5*-2 -2) // ^ that's result of modulo.

javascript

Comments

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -