---
title: "Functions"
description: "Built-in functions can be used to manipulate numeric results within your formula."
canonical: "https://www.questportal.com/documentation/Wf1ydCng96/functions"
section: "Documentation / Dice / Roll Formulas / Advanced Features"
source: "Quest Portal documentation"
version: 237
---

# Functions

Built-in functions can be used to manipulate numeric results within your formula.

- \`floor(expression)\` - Rounds the result of the expression _down_ to the nearest whole number.
  _Example:_ \`floor(1d10 / 2)\` -> If 1d10 is 7, \`floor(3.5)\` -> Result \`3\`.
- \`ceil(expression)\` - Rounds the result of the expression _up_ to the nearest whole number.
  _Example:_ \`ceil(1d10 / 2)\` -> If 1d10 is 7, \`ceil(3.5)\` -> Result \`4\`.
- \`round(expression)\` - Rounds the result of the expression to the _nearest_ whole number (0.5 rounds up).
  _Example:_ \`round(1d10 / 2)\` -> If 1d10 is 7, \`round(3.5)\` -> Result \`4\`. If 1d10 is 6, \`round(3.0)\` -> Result \`3\`.
- \`abs(expression)\` - Returns the absolute (non-negative) value of the expression's result.
  _Example:_ \`abs(d6 - d6)\` -> If rolls are \[2, 5\], \`abs(2 - 5) = abs(-3)\` -> Result \`3\`.
- \`min(a, b)\` - Returns the **smaller** of two numbers.
  _Example:_ \`min(1d8, 1d10)\` -> If the rolls are 5 and 7, the result is \`5\`.
- \`max(a, b)\` - Returns the **larger** of two numbers.
  _Example:_ \`max(1d8, 1d10)\` -> If the rolls are 5 and 7, the result is \`7\`.
- \`if(condition, then_expr, else_expr)\` - Evaluates the \`condition\`. If the condition's result is non-zero (true), it evaluates and returns \`then_expr\`. Otherwise (if the condition is zero/false), it evaluates and returns \`else_expr\`.

  _Example:_ \`if(d20>10, d8, d4)\` -> If d20 rolls 15 (\`15>10\` is true), the formula evaluates \`d8\`. If d20 rolls 5 (\`5>10\` is false), the formula evaluates \`d4\`.

---

Part of the [Quest Portal documentation](https://www.questportal.com/documentation.md) (Documentation / Dice / Roll Formulas / Advanced Features). HTML version: <https://www.questportal.com/documentation/Wf1ydCng96/functions>.
