Closed magoz closed 2 years ago
I've encountered this unexpected behavior when rounding negative numbers.
currency(10.4, { increment: 1 }).format() // 10 currency(10.5, { increment: 1 }).format() // 11 currency(10.6, { increment: 1 }).format() // 11 currency(-10.4, { increment: 1 }).format() // -10 currency(-10.49, { increment: 1 }).format() // -10 correct currency(-10.5, { increment: 1 }).format() // -10 <------- this should be -11 currency(-10.51, { increment: 1 }).format() // -11 correct currency(-10.6, { increment: 1 }).format() // -11
The odd thing is that it only happens with -10.5, not with -10.49 or -10.51.
-10.5
-10.49
-10.51
Am I missing something is this a bug?
Rounding in currently currency.js follows the half round-up method, meaning half values get rounded towards positive infinity. This isn't currently a bug, but there is a request to support multiple types of rounding.
I've encountered this unexpected behavior when rounding negative numbers.
The odd thing is that it only happens with
-10.5
, not with-10.49
or-10.51
.Am I missing something is this a bug?