UserLand Software Home  |  Manila  |  Radio  |  Support  |  News

DocServer

Prev | Next | Basic Verbs > mod

mod

Syntax mod (num, base)

num % base

Params num is a number. It acts as the dividend in this operation.

base is a number. It acts as the divisor in this operation.

Action Divides num by base and calculates the remainder. (In mathematical terms, this function calculates num modulo base.)

Returns The remainder that results when num is divided by base. (In mathematical terms, this function returns num modulo base.)

Examples mod (43, 10)

   » 3 // 43/10 = 4 with a remainder of 3

mod (16, 2) == 0 //determine if a value is even

   » true

mod (3, 4) // 3/4=0 with a remainder of 3

   » 3

398 % 3

   » 2

-1 % 24 //mod of a negative number is negative

   » -1

Notes You can also use the % operator to carry out modulus calculations. This is an infix operator which is placed between the num and base.

Prev | Next | Basic Verbs > mod

Anonymization by Anonymouse.org ~ Adverts
Anonymouse better ad-free, faster and with encryption?
X