Hi Guys,
I am observing inconsistent behaviour of output coming from the built-in service pub.string:numericFormat.
Output varies for different sets of inputs.
Error messages / full error message screenshot / log file:
The issue with the service is its use of Double within the implementation. It is not a bug. It is not an artifact of older versions. It is the nature of floating point, which is precise but not always accurate.
The IS docs indicate the service uses the HALF_EVEN rounding mode (the default of the DecimalFormat class being used), but because of the use of Double (with native double underneath that) the accuracy is lost.
You’ll want to look elsewhere for numeric formatting that does not use float/double to do the work. Indeed, if at all possible, you may want to avoid formatting numbers within wM IS altogether unless you have no other choice. Let the endpoints that care about it do whatever manipulation they may need.
If I had a penny for every time I’ve seen Rob explain issues related to binary floating-point arithmetic, I’d have several pennies now. The first time was probably in the early to mid 2000’s on wmusers.com. Thanks for the consistency throughout the years, @reamon !
It is interesting how long wM IS has been around and how long we’ve been working with it.
And a little disappointing that floating point is still so broadly misunderstood (though not necessarily in this case – not easy to know how this service is implemented).