Moodle - Math Operator Syntax

A listing and basic guide for the use of operators on calculations within Moodle

Declaring a random variable (e.g. variable x) : {x}
Addition: +
Subtraction: -
Multiplication: * (note: the multiplication symbol must be used.  3*x will work while 3x will not)
Division: /
Pi: pi() (please note that this is the only predefined constant.  For example, there is no e() function)

Function Explanation
absAbsolute value
acosArc cosine -- output in radians.
acoshInverse hyperbolic cosine -- output in radians.
asinArc sine -- output in radians.
asinhInverse hyperbolic sine.-- output in radians.
atan2Arc tangent of two variables -- pass in two values like (y, x), and you'll get the atah(y/x), adjusted to the proper quadrant. (Note: The variables are in the reverse order to atan2(x,y) in Excel) Output is radians.
atanArc tangent -- output in radians.
atanhInverse hyperbolic tangent-- output in radians.
bindecBinary to decimal
ceilRound fractions up
cosCosine -- in radians!!! Convert your degree measurement to radians before you take the cos of it.
coshHyperbolic cosine -- in radians!!! Convert your degree measurement to radians before you take the cosh of it.
decbinDecimal to binary
decoctDecimal to octal
deg2radConverts the number in degrees to the radian equivalent
expCalculates the exponent of e
expm1Returns exp(number) - 1, computed in a way that is accurate even when the value of number is close to zero
floorRound fractions down
fmodReturns the floating-point modulus of two numbers - i.e. the remainder when the first is divided by the second.
is_finiteFinds whether a value is a legal finite number
is_infiniteFinds whether a value is infinite
is_nanFinds whether a value is not a number
log10Base-10 logarithm
log1pReturns log(1 + number), computed in a way that is accurate even when the value of number is close to zero
logNatural logarithm (ln)
maxFind highest value
minFind lowest value
octdecOctal to decimal
pi()Get value of pi - the function does not take an argument, like in Excel.
pow (numberToRaise, NumberRaisedTo)Exponential expression
For example:  x3 would be written as pow(x,3)
rad2degConverts the radian number to the equivalent number in degrees
randGenerate a random integer
roundRounds a float
sinSine -- in radians!!! Convert your degree measurement to radians before you take the sin of it.
sinhHyperbolic sine -- in radians!!! Convert your degree measurement to radians before you take the sinh of it.
sqrtSquare root
tanTangent -- in radians!!! Convert your degree measurement to radians before you take the tan of it.
tanhHyperbolic tangent -- in radians!!! Convert your degree measurement to radians before you take the tanh of it.


For a more comprehensive list of operators and more information see the Calculated Question Moodle docs page
For information on how to use the DragMath Equation Editor, visit the Equation Editor page.



Keywords:math, calculate, question, quiz, operator, syntax, 2.3, 2.4   Doc ID:26756
Owner:Elizabeth H.Group:Moodle
Created:2012-10-10 12:17 CDTUpdated:2014-08-20 14:03 CDT
Sites:DoIT Help Desk, Moodle
Feedback:  4   0