Try this: call pub.math.multiplyFloats with 3 and 13.20
Depending upon IS fixes and some other aspects, chances are the result is 39.599999999999994 instead of 39.6.
This is because float/double are inaccurate. Useful in many contexts but for general business applications, it is not. This is not specific to Java. Or any OS. Or any specific runtime. It is the nature of binary arithmetic.
I’ve seen applications the are littered with using float/double and round and trunc operations in attempts to “fix the JVM bug”. They are not bugs.
Avoid float/double unless you know you need it for non-monetary purposes. I fully suspect roundNumber is a victim of this too. Write your own BigDecimal services to use instead. Doing so is easy. We named ours addDecimals, multiplyDecimals, etc. and have the signatures match the same inputs and outputs as the WmPublic services. Here is an example of one of them:
public static final void addDecimals(IData pipeline) throws ServiceException {
IDataCursor idc = pipeline.getCursor();
String num1 = IDataUtil.getString(idc, "num1");
String num2 = IDataUtil.getString(idc, "num2");
// Note that these constructors may throw NPE if
// num1 and/or num2 are not passed to the service.
// This mimics pub.math:addFloats.
java.math.BigDecimal n1 = new java.math.BigDecimal(num1);
java.math.BigDecimal n2 = new java.math.BigDecimal(num2);
IDataUtil.put(idc, "value", n1.add(n2).toString());
idc.destroy();
}
#Integration-Server-and-ESB#webMethods#Flow-and-Java-services#B2B-Integration