_addx, _subx, _mulx, _divx OI9.3 (Basic+)
At 10 AUG 2011 08:50:16AM Mary Jean Blink wrote:
In the Revelation Software's August 2011 Newsletter, the 9.3 functions of _addx, _subx, _mulx, _divx are introduced.
Questions:
1. In the _addx example it is not clear if rounding occurs or not. Does it round? If it is, does the system do traditional rounding or bankers rounding (to the nearest even)?
2. Do these new functions handle multi-valued arrays? If not, could you also include _addxarray, _subxarray, mulxarray, and _divxarray functions too? The Newsetter indicates that you send 2 values, but what will happen if those two values are strings with a dynamic array delimiter?
3. Should we expect than any new functions in OI will now begin with an underscore character?
4. If no precision is explicitly indicated, it appears that the result of _divx will always pad to 128 decimal places (even if they are not required for a precise result). Is that the only one of the 4 functions that does this? In other words, if I have
a = 16
b = 4
x2 = _divx( a, b ); * For full precision.
x2 will result in 4.000000000000000000000000… (for 128 places)?
At 11 AUG 2011 12:09PM carl pates wrote:
Mary,
1) Traditional rounding.
2) No - they are not array aware.
3) No - The underscore relates to the existing convention of extended operators such as _EQX, _NEX and so on.
4) With the _addx, _subx and _mulx if you specify a greater number of decimal places than is contained in the answer it will be padded. If you specify less precision it will be rounded. If you don't specify a precision (or pass -1) you will get the exact number of decimal places required to contain the answer.
Divsion is different than the other operators. With the precision argument here you are telling the engine how many decimal places you wish to calculate before returning the result - this is because division cannot be counted on to produce non-repeating decimals. If you do not specify a precision then a default precision of 128 decimal places is used. If number of decimal places you specify is more than that contained in the result then the result is padded with trailing zeros.
At 11 AUG 2011 12:23PM Mary Jean Blink wrote:
Carl,
Thank you for the clarification. All makes sense.
MJ