TinTin++ Mud Client Manual
         MATH

Command: #math {variable} {expression}

         Performs math operations and stores the result in a variable.  The math
         follows a C-like precedence, as follows, with the top of the list
         having the highest priority.

         Operators       Priority     Function
         ------------------------------------------------
         !               0            logical not
         ~               0            bitwise not
         d               1            integer random dice
         *               2            integer multiply
         **              2            integer power
         /               2            integer divide
         //              2            integer sqrt // 2 or cbrt // 3
         %               2            integer modulo
         +               3            integer addition
         -               3            integer subtraction
         <<              4            bitwise shift
         >>              4            bitwise shift
         ..              4            integer range
         >               5            logical greater than
         >=              5            logical greater than or equal
         <               5            logical less than
         <=              5            logical less than or equal
         ==              6            logical equal (can use regex)
         ===             6            logical equal (never regex)
         !=              6            logical not equal (can use regex)
         !==             6            logical not equal (never regex)
          &              7            bitwise and
          ^              8            bitwise xor
          |              9            bitwise or
         &&             10            logical and
         ^^             11            logical xor
         ||             12            logical or
         ?              13            logical ternary if (unfinished code)
         :              14            logical ternary else 

         True is any non-zero number, and False is zero.  Parentheses () have
         highest precedence, so inside the () is always evaluated first.

         Strings must be enclosed in " " or { } and in the case of an == or
         != operation a regex is performed with the regular expression in the
         right-hand string. In the case of a <= or >= operation the alphabetic
         order is compared.

         The #if and #switch commands use #math. Several commands accepting
         numeric input allow math operations as well, such as #delay.

         Floating point precision is added by using the decimal . operator or
         using #format with the %f flag character.

Example: #math {heals} {$mana / 40}
         Assuming there is a variable $mana, divides its value by 40 and stores
         the result in $heals.

Example: #action {^You receive %0 experience} {updatexp %0}
         #alias updatexp {#math {xpneed} {$xpneed - %0}
         Let's say you have a variable which stores xp needed for your next
         level.  The above will modify that variable after every kill, showing
         the amount still needed.

Example: #action {%0 tells %1}
           {#if {{%0} == {Bubba} && $afk} {reply I'm away, my friend.}}
         When you are away from keyboard, it will only reply to your friend.

Related: cat, format, function, local, mathematics, replace, script and variable.