@num
Evaluate an arithmetic expression or convert a value to a number.
On-chain (@num!): Composes live calls and constants with on-chain arithmetic: + - * / % ^ and xor.
Returns: number
Syntax
Section titled “Syntax”@num(...tokens)Arguments
Section titled “Arguments”| Name | Type | Description |
|---|---|---|
[...tokens] | any | Arithmetic expression (e.g. $a + $b * 2) |
Examples
Section titled “Examples”# Basic arithmeticset $sum @num(1 + 2)
# Exponentiationset $pow @num(2 ^ 10)
# Expression with variablesset $a 10set $b 3set $result @num($a * $b + 1)
# Convert a string to numberset $n @num("42")See Also
Section titled “See Also”- @num.format — format with decimals (like
formatUnits) - @num.parse — parse a decimal string (like
parseUnits) - @bool — boolean expressions
On-chain face (@num!)
Section titled “On-chain face (@num!)”Compose live calls and constants with on-chain arithmetic (+ - * / % ^, xor), evaluated at assertion time via the operators contract.