aboutsummaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
Diffstat (limited to 'docs')
-rw-r--r--docs/nums.md26
1 files changed, 25 insertions, 1 deletions
diff --git a/docs/nums.md b/docs/nums.md
index 7a86a585..02859d28 100644
--- a/docs/nums.md
+++ b/docs/nums.md
@@ -129,7 +129,7 @@ called either on the type itself: `Num.sqrt(x)` or as a method call:
- [`func atanh(x: Num -> Num)`](#atanh)
- [`func cbrt(x: Num -> Num)`](#cbrt)
- [`func ceil(x: Num -> Num)`](#ceil)
-- [`clamped(x, low, high: Num -> Num)`](#clamped)
+- [`func clamped(x, low, high: Num -> Num)`](#clamped)
- [`func copysign(x: Num, y: Num -> Num)`](#copysign)
- [`func cos(x: Num -> Num)`](#cos)
- [`func cosh(x: Num -> Num)`](#cosh)
@@ -155,6 +155,7 @@ called either on the type itself: `Num.sqrt(x)` or as a method call:
- [`func near(x: Num, y: Num, ratio: Num = 1e-9, min_epsilon: Num = 1e-9 -> Bool)`](#near)
- [`func nextafter(x: Num, y: Num -> Num)`](#nextafter)
- [`func parse(text: Text -> Num?)`](#parse)
+- [`func percent(n: Num -> Text)`](#percent)
- [`func rint(x: Num -> Num)`](#rint)
- [`func round(x: Num -> Num)`](#round)
- [`func scientific(n: Num, precision: Int = 0 -> Text)`](#scientific)
@@ -922,6 +923,29 @@ as a number.
---
+### `percent`
+Convert a number into a percentage text with a percent sign.
+
+```tomo
+func percent(n: Num, precision: Int = 0 -> Text)
+```
+
+- `n`: The number to be converted to a percent.
+- `precision`: The number of decimal places. Default is `0`.
+
+**Returns:**
+A text representation of the number as a percentage with a percent sign.
+
+**Example:**
+```tomo
+>> 0.5:percent()
+= "50%"
+>> (1./3.):percent(2)
+= "33.33%"
+```
+
+---
+
### `rint`
Rounds a number to the nearest integer, with ties rounded to the nearest even integer.