Skip to content

Latest commit

 

History

History
45 lines (31 loc) · 815 Bytes

File metadata and controls

45 lines (31 loc) · 815 Bytes
title @num

Evaluate an arithmetic expression or convert a value to a number.

Returns: number

Syntax

@num(...tokens)

Arguments

Name Type Description
[...tokens] any Arithmetic expression (e.g. $a + $b * 2)

Examples

# Basic arithmetic
set $sum @num(1 + 2)

# Exponentiation
set $pow @num(2 ^ 10)

# Expression with variables
set $a 10
set $b 3
set $result @num($a * $b + 1)

# Convert a string to number
set $n @num("42")

See Also

  • @num.format — format with decimals (like formatUnits)
  • @num.parse — parse a decimal string (like parseUnits)
  • @bool — boolean expressions