I'd like to understand the behavior of decimal rounding that happens implicitly when using Intl.NumberFormat.prototype.format(). The MDN documentation of the format function lacks a clear description of that behavior.
Let's take the following piece of code as an example:
const amount = 654321.985;
const formattedAmount = new Intl.NumberFormat('en-EN', {
style: 'currency',
currency: 'EUR',
}).format(amount);
console.log(formattedAmount); // => €654,321.99
What is the rounding strategy in this case and what it depends on? I would assume that there are many factors involved like the browser, locale and currency, but couldn't find a confirmation to that.
After playing around with this sample, I can see that the decimal part is rounded up a cent, and down for anything below, i.e. .9849 becomes .98. The strategy seems to follow the nearest integer, ties to even rule. At the same time, I understand that the logic can be more complicated given the ECMAScript specification.