GOLF(2gg)

NAME
number-expressions - Golf documentation (numbers)

DESCRIPTION
A number expression uses operators plus (+), minus (-), multiply (*), divide (/) and modulus (%), 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).

SEE ALSO
 Numbers

abs-number number-expressions number-string set-number string-number See all documentation