# Logic Syntax

These functions can be used in any logic field in CheckFirst.

Functions marked with \* are also available in an [operator format](https://guide.checkfirst.gov.sg/features/logic/calculator-logic#operator-keyboard-shortcuts).

| Function name      | Description                                                                                                            | Function                                                                      | Example                                                                              |
| ------------------ | ---------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------- | ------------------------------------------------------------------------------------ |
| \*Add              | Add two or more values, x + y.                                                                                         | [add(x, y)](https://mathjs.org/docs/reference/functions/add.html)             | add(N1,N2)                                                                           |
| \*Subtract         | Subtract two values, x - y.                                                                                            | [subtract(x, y)](https://mathjs.org/docs/reference/functions/subtract.html)   | subtract(N1,N2)                                                                      |
| \*Multiply         | Multiply two or more values, x \* y.                                                                                   | [multiply(x, y)](https://mathjs.org/docs/reference/functions/multiply.html)   | multiply(N1,N2)                                                                      |
| \*Divide           | Divide two values, x / y.                                                                                              | [divide(x, y)](https://mathjs.org/docs/reference/functions/divide.html)       | divide(N1,2)                                                                         |
| \*Power            | Calculates the power of x to y, x ^ y.                                                                                 | [pow(x, y)](https://mathjs.org/docs/reference/functions/pow.html)             | pow(N1,2)                                                                            |
| \*Square           | Compute the square of a value, x \* x.                                                                                 | [square(x)](https://mathjs.org/docs/reference/functions/square.html)          | square(N1)                                                                           |
| Square root        | Calculate the square root of a value.                                                                                  | [sqrt(x)](https://mathjs.org/docs/reference/functions/sqrt.html)              | sqrt(N1)                                                                             |
| Round              | Round a value towards the nearest integer.                                                                             | [round(x,n)](https://mathjs.org/docs/reference/functions/round.html)          | round(N1,2)                                                                          |
| Round - Floor      | Round a value towards minus infinity.                                                                                  | [floor(x)](https://mathjs.org/docs/reference/functions/floor.html)            | floor(N1)                                                                            |
| Round - Ceiling    | Round a value towards plus infinity. If x is complex, both real and imaginary parts are rounded towards plus infinity. | [ceil(x)](https://mathjs.org/docs/reference/functions/ceil.html)              | ceil(N1)                                                                             |
| Max                | Compute the maximum value of a matrix or a list with values.                                                           | [max(a, b, c, …)](https://mathjs.org/docs/reference/functions/max.html)       | max(N1,N2,N3)                                                                        |
| Min                | Compute the minimum value of a matrix or a list of values.                                                             | [min(a, b, c, …)](https://mathjs.org/docs/reference/functions/min.html)       | min(N1,N2,N3)                                                                        |
| Mean               | Compute the mean value of matrix or a list with values.                                                                | [mean(a, b, c, …)](https://mathjs.org/docs/reference/functions/mean.html)     | mean(N1,N2,N3)                                                                       |
| Median             | Compute the median of a matrix or a list with values.                                                                  | [median(a, b, c, …)](https://mathjs.org/docs/reference/functions/median.html) | median(N1,N2,N3)                                                                     |
| Mode               | Computes the mode of a set of numbers or a list with values(numbers or characters).                                    | [mode(a, b, c, …)](https://mathjs.org/docs/reference/functions/mode.html)     | mode(N1,N2,N3)                                                                       |
| Standard deviation | Compute the standard deviation of a matrix or a list with values.                                                      | [std(a, b, c, …)](https://mathjs.org/docs/reference/functions/std.html)       | std(N1,N2,N3)                                                                        |
| Sum                | Compute the sum of a matrix or a list with values.                                                                     | [sum(a, b, c, …)](https://mathjs.org/docs/reference/functions/sum.html)       | sum(N1,N2,N3)                                                                        |
| If/Else            | Executes an action if a condition is met (true) and another action if that condition is not met (false).               | ifelse(conditions,then,else...)                                               | <p>ifelse((O1>1) and (O2>1),true,false)<br></p><p>ifelse(O1></p>                     |
| Count if           | Count the number of elements that fulfil a condition.                                                                  | countif(\[Range],condition)                                                   | countif(\[O1,O2,O3], "Correct")                                                      |
| Round              | Round a number **x** to **n** decimal place                                                                            | round(x,n)                                                                    | <p>round(O2,3)</p><p>round the numeric output of logic O2 to 3 decimal places.  </p> |

[*View the full logic syntax list*](https://guide.checkfirst.gov.sg/faq/full-logic-syntax-list) *accepted by CheckFirst*
