Difference between revisions of "LavishScript:Mathematical Formulae"
Jump to navigation
Jump to search
Line 1: | Line 1: | ||
== Introduction == | == 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 ([[DataType:string|string]] provides members for working with text strings). | + | 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 ([[DataType:string|string]] provides members for working with text strings). Certain keywords are treated as specific numbers in mathematical formulae. '''TRUE''' is treated as '''1'''. '''FALSE''' and '''NULL''' are treated as '''0'''. |
== Operators == | == Operators == |
Revision as of 06:58, 22 February 2005
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). Certain keywords are treated as specific numbers in mathematical formulae. TRUE is treated as 1. FALSE and NULL are treated as 0.
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) |