LavishScript:Mathematical Formulae

From Lavish Software Wiki
(Redirected from LavishScript:TRUE)
Jump to navigation Jump to search


Mathematical formulae (math operators) are evaluated whenever a command, object or control structure calls for a formula or condition. Formulae allow only numeric operations, they may not be used on text strings (string provides members for working with text strings).


The following table lists operators in order of precedence -- topmost are evaluated first. Consecutive items colored equally in the table are evaluated left to right with the same precedence.

Operator Operation
! Logical NOT - X (result is 0 or 1)
~ Bitwise NOT - X (flips every bit. e.g. 1 becomes -2)
^^ Power - X to Y
* Multiply - X by Y
/ Divide - X by Y
\ Divide (Integer) - X by Y. (Remember to escape it! x\\y)
% Modulus - X by Y
+ Add - X and Y
- Subtract - Y from X
<< Bitwise shift left - X by Y
>> Bitwise shift right - X by Y
> Greater than - X vs Y (result is 0 or 1)
>= Greater than or equal to - X vs Y (result is 0 or 1)
< Less than - X vs Y (result is 0 or 1)
<= Less than or equal to - X vs Y (result is 0 or 1)
== Equal - X vs Y (result is 0 or 1)
!= Not equal - X vs Y (result is 0 or 1)
& Bitwise AND - X and Y
^ Bitwise XOR - X xor Y
| Bitwise OR - X or Y
&& Logical AND - X and Y (result is 0 or 1)
|| Logical OR - X or Y (result is 0 or 1)


Operations can be grouped with parentheses ( and ) in standard form. The enclosed expression will be evaluated first, thus providing a way to change the order of operations in a formula.

Note that in contrast to algebraic form, ( and ) next to another expression without an operator is not an implied multiplication. You must explicitly specify the operation to use with the parentheses.


Certain keywords are treated as specific numbers in mathematical formulae. TRUE is treated as 1. FALSE and NULL are treated as 0.


  • The == and != operators, when used in floating point math as opposed to Math.Calc64, treat any two numbers within 0.00000001 of each other as equal.
  • Note that Calc64 is a misnomer, as its purpose is to provide 64-bit integer math, whereas Math.Calc and all other calculations use 64-bit floating point math.