IBM webMethods Hybrid Integration

IBM webMethods Hybrid Integration

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.


#TechXchangePresenter
 View Only
Expand all | Collapse all

Pub.math.absolutevalue rounding granularity?

  • 1.  Pub.math.absolutevalue rounding granularity?

    Posted Fri April 14, 2023 02:57 PM

    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?


    #Integration-Server-and-ESB
    #webMethods


  • 2.  RE: Pub.math.absolutevalue rounding granularity?

    Posted Wed April 19, 2023 03:32 AM

    Hi @Andy_Simmons1,

    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.

    HTH,
    Sree


    #webMethods
    #Integration-Server-and-ESB


  • 3.  RE: Pub.math.absolutevalue rounding granularity?

    Posted Wed April 19, 2023 12:56 PM

    You may find the exchange at How to convert an integer (int, Short, Long, Float, Double) to String - #7 by John_Carter4 to be of interest.

    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();		
    
    

    #Integration-Server-and-ESB
    #webMethods