Math
Operator | Compatible types | Description |
+ | Integer, Decimal, Text | For numerics, adds the lhs and rhs values and returns the result. For text values, concatenates lhs with rhs and returns the result: var x = 45 + 3.3; var y = 'hello' + ' world'; |
- | Integer, Decimal | Subtracts rhs from lhs and returns the result: var x = 4.04 - 3; |
* | Integer, Decimal | Multiplies lhs and rhs and returns the result: var x = 34 * 0.993; |
/ | Integer, Decimal | Divides lhs by rhs and returns the result: var x = 33 / 9.9; Note that like C#, irScript uses integer division; this means that division of two integers always results in an integer return value. However, unlike C#, irScript supports division of integers by non-integers, and vice versa; in these cases,normal irScript type conversion rules apply (see below). |
% | Integer, Decimal | Divides lhs by rhs and returns the remainder: var x = 100 / 5.3; |
Note that irScript performs data type conversions during math operations, for integral numeric types. Note also that any floating-point representations later accessible outside irScript (in the InRule rule engine proper) are converted to System.Decimal.
LHS type | RHS type | Result type |
Int64 | Int16, Int32, Int64, UInt16, UInt32 Int64 UInt64, Single, Double, Decimal <RHS type> Null Null | ||||||
Int32 | Int16, UInt16, Int32 Int32 Int64, UInt32, UInt64, Single, Double, Decimal <RHS type> Null Null | ||||||
Int16 | Int16 Int16 Int32, Int64, UInt16, UInt32, UInt64, Single, Double, Decimal <RHS type> Null Null | ||||||
UInt64 | Int16, Int32, Int64, UInt16, UInt32, UInt64 UInt64 Single, Double, Decimal <RHS type> Null Null | ||||||
UInt32 | Int16, UInt16, Int32, UInt32 UInt32 Int64, UInt64, Single, Double, Decimal <RHS type> Null Null | ||||||
UInt16 | Int16, UInt16 UInt16 Int32, Int64, UInt32, UInt64, Single, Double, Decimal <RHS type> Null Null | ||||||
Decimal | Int16, Int32, Int64, UInt16, UInt32, UInt64, Decimal, Single, Double Decimal Null Null | ||||||
Single | Int16, Int32, Int64, UInt16, UInt32, UInt64, Single Single Double, Decimal <RHS type> Null Null | ||||||
Double | Int16, Int32, Int64, UInt16, UInt32, UInt64, Double, Single Double Decimal <RHS type> Null Null |