# LavishScript:Mathematical Formulae

## Contents

## Introduction

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

## 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. (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) |

## Grouping

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.

## Keywords

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