Extended Math Functions in OpenInsight 9.3 and above
_addx (add)
_subx (subtract)
_mulx (multiply)
_divx (divide)
_eqx (equal, to full precision)
_nex (not equal, to full precision)
_ltx (less than, to full precision)
_gtx (greater than, to full precision)
_lex (less than or equal, to full precision)
_gex (greater than or equal, to full precision)
_cmpx (compare, to full precision)
These functions allow you to perform math operations using full precision or a specified precision.
For _addx, _subx, and _mulx, the calculations are performed at full precision, and the returned result is rounded or padded as needed if a specific precision is provided. For _divx, the calculation is limited to the number of decimal places specified, or 128 places if none is specified, and then the return result is rounded or padded to the specific precision if any is provided.
NOTE: In OpenInsight 10.x, extended precision operations can be enabled for regular math operations. For details, please see this article.
The _addx function adds two numbers. The required precision (number of decimal places) is an optional parameter. The syntax is as follows:
ans = _addx( num1, num2 [, decimalPlaces] )
For example:
a = "10.3456" b = "4.567" decimalPlaces = 2 x1 = _addx( a, b, decimalPlaces ) x2 = _addx( a, b ); * // For full precision. // x1 will return 14.91 // x2 will return 14.9126
The _subx function subtracts two numbers. The required precision (number of decimal places) is an optional parameter. The syntax is as follows:
ans = _subx( num1, num2 [, decimalPlaces] )
For example:
a = "10.3456" b = "4.567" decimalPlaces = 2 x1 = _subx( a, b, decimalPlaces ) x2 = _subx( a, b ); * // For full precision. // x1 will return 5.78 // x2 will return 5.7786
The _mulx function multiplies two numbers. The required precision (number of decimal places) is an optional parameter. The syntax is as follows:
ans = _mulx( num1, num2 [, decimalPlaces] )
For example:
a = "10.3456" b = "4.567" decimalPlaces = 2 x1 = _mulx( a, b, decimalPlaces ) x2 = _mulx( a, b ); * // For full precision. // x1 will return 47.25 // x2 will return 47.2483552
The _divx function divides two numbers. The required precision (number of decimal places) is an optional parameter. The syntax is as follows:
ans = _divx( num1, num2 [, decimalPlaces] )
For example:
a = "10.3456" b = "4" decimalPlaces = 4 x1 = _divx( a, b, decimalPlaces ) x2 = _divx( a, b ); * // For full precision. // x1 will return 2.6140 // x2 will return 2.6140000000000 ...
<padded to 128 decimal places>
Equal, to full precision
For example:
a = "10.3456" b = "10.34567" If a _eqx b Then …
Not equal, to full precision
For example:
a = "10.3456" b = "10.34567" If a _nex b Then …
Less than, to full precision
For example:
</code> a = "10.3456"
b = "10.34567"
If a _ltx b Then … </code>
Greater than, to full precision
For example:
a = "10.3456" b = "10.34567" If a _gtx b Then …
Less than or equal, to full precision
For example:
a = "10.3456" b = "10.34567" If a _lex b Then …
Greater than or equal, to full precision
For example:
a = "10.3456" b = "10.34567" If a _gex b Then …
Compare two numbers, to full precision. Returns 1 if first number is greater than the 2nd, 0 if the first number is equal to the 2nd, and -1 if the first number is less than the 2nd
For example:
a = "10.3456" b = "10.34567" rslt = _cmpx(a,b) If rslt == 1 Then …