|
|
(7 intermediate revisions by the same user not shown) |
Line 1: |
Line 1: |
| [https://docs.moodle.org/33/en/Formulas_question_type < Formulas question type] | | #REDIRECT [[Formulas:_Operators]] |
| | |
| ==Operators==
| |
| | |
| The following operators, available in the Formulas question type, are JavaScript operators. For more details, see for example [http://www.w3schools.com/jsref/jsref_operators.asp w3schools/jsref/jsref_operators].
| |
| | |
| {| class="nicetable"
| |
| |-
| |
| ! Operator
| |
| ! Definition
| |
| |-
| |
| | <b>Arithmetic Operators</b>
| |
| |
| |
| |-
| |
| | +
| |
| | addition
| |
| |-
| |
| | -
| |
| | subtraction
| |
| |-
| |
| | *
| |
| | multiplication
| |
| |-
| |
| | /
| |
| | division
| |
| |-
| |
| | %
| |
| | modulus (division remainder)
| |
| |-
| |
| | <b>Assignment Operators</b>
| |
| |
| |
| |-
| |
| | =
| |
| | assigns a value to a variable
| |
| |-
| |
| | <b>Comparison Operators</b>
| |
| |
| |
| |-
| |
| | ==
| |
| | equal to
| |
| |-
| |
| | !=
| |
| | not equal
| |
| |-
| |
| | >
| |
| | greater than
| |
| |-
| |
| | <
| |
| | less than
| |
| |-
| |
| | >=
| |
| | greater than or equal to
| |
| |-
| |
| | <=
| |
| | less than or equal to
| |
| |-
| |
| | <b>Conditional (Ternary) Operator</b>
| |
| |
| |
| |-
| |
| | ? :
| |
| | conditional operator
| |
| |-
| |
| | <b>Logical Operators</b>
| |
| |
| |
| |-
| |
| | &&
| |
| | and
| |
| |-
| |
| | | |
| |
| | or
| |
| |-
| |
| | !
| |
| | not
| |
| |-
| |
| | <b>Bitwise Operators</b>
| |
| |
| |
| |-
| |
| | &
| |
| | AND
| |
| |-
| |
| | |
| |
| | OR
| |
| |-
| |
| | ~
| |
| | NOT
| |
| |-
| |
| | ^
| |
| | XOR<br>(Note that ^ means "power" in algebraic formulas)
| |
| |-
| |
| | <<
| |
| | left shift
| |
| |-
| |
| | >>
| |
| | right shift
| |
| |}
| |
| | |
| [https://docs.moodle.org/33/en/Formulas_question_type < Formulas question type]
| |