LavishScript:Mathematical Formulae

From Lavish Software Wiki
Revision as of 06:09, 22 February 2005 by Lax (talk | contribs)
(diff) ←Older revision | view current revision (diff) | Newer revision→ (diff)
Jump to navigation Jump to search

Introduction

Mathematical formulae are evaluated whenever a command or Top-Level Object 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).

Operators

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
% 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)