I’ve found that it appears that, by default, pub.math.absoluteValue rounds its output to 3 decimal places, so the absolute value of 0.0047 would be returned as 0.005. Obviously, this is problematic, since nobody expects calculating the absolute value to actually alter any part of the value other than the sign. I’m seeing this in both 10.3 and 10.11.
Does anybody know if there’s an extended setting (or something else) that can control whether rounding is performed as part of the absolute value calculation, or at least control how many decimal places it rounds to? Or am I going to have to abandon this service and write my own replacement that works properly?
As it appears this is how it’s designed and for now, you might want to write a replacement that would suffice your requirement. I would also recommend you raise a ticket with support for us to look into this more closely to arrive at a solution if there needs a correction.
It appears the absolute service (and possibly others) try to use BigDecimal to avoid the inherent inaccuracies of float/double but then subvert that effort by having an intermediate double type.
Likely need to follow the suggestion from @Sreekanth_Siddapur_Channakeshava to create your own replacement that avoids using float/double at any step. Here is simplistic code that is not as robust in terms of the input handling as the built-in service, but does not have a double in the mix.
IDataCursor idc = pipeline.getCursor();
String number = IDataUtil.getString(idc, "number");
IDataUtil.put(idc, "positiveNumber", new java.math.BigDecimal(number).abs().toString());
idc.destroy();