Number expressions

A number expression uses operators plus (+), minus (-), multiply (*), divide (/), modulus (%), bitwise operators (& for and, | for or, ^ for xor and ~ for negation)  as well as parenthesis (). For example:
 set-number n1 = 10+(4*n2-5)%3

You can use number expressions anywhere number is expected as an input to any statement.

Note that character constants (such as 'A', 'z' etc.) are considered numbers with the value equal to their single-byte ASCII equivalent (i.e. unsigned numbers 0-255), for example this will assign 65 to "num":
 set-number num = 'A'

Any subscripted string is also considered a number, for instance "num" would be 117 (since 's' is 115):
 set-string str = 'some'
 set-number num = str[0] + 2

Other than decimals and character constants, you can also use hexadecimal numbers (such as 0xffaa), and octal numbers (such as 0710).
String subscription
You can access each byte of a string as an unsigned 8-bit number:
 set-string str = "GOAT"
 set-string num = 10+str[2]

Variable num will have a value of 75 (10+'A' or 10+65).
Subscription shortcut
You can reference number arrays elements (see new-array) by using subscription operator ([]), for instance:
 new-array narr type number
 write-array narr key 0 value 10
 write-array narr key 1 value narr[0]
 set-number n = 1 + narr[1] * 2



Copyright (c) 2019-2025 Gliim LLC. All contents on this web site is "AS IS" without warranties or guarantees of any kind.