MikeMcl / bignumber.js

A JavaScript library for arbitrary-precision decimal and non-decimal arithmetic
http://mikemcl.github.io/bignumber.js
MIT License
6.63k stars 743 forks source link

0 raised to power of n, where n is negative number with more than 15 digits returns 0 (not Infinity) #338

Closed Kolobamanacas closed 1 year ago

Kolobamanacas commented 1 year ago

Repro steps:

import BigNumber from "bignumber.js";

console.log(new BigNumber(0).exponentiatedBy('-123456789012345').toString()) // Returns Infinity (ok).
console.log(new BigNumber(0).exponentiatedBy('-12345678901234567890123456789012345678901234567890').toString()) // Returns 0 (seems like not ok).

It seems to me, that this behavior is somewhat inconsistent and zero raised to power of negative number should return Infinity independent from power's length.

MikeMcl commented 1 year ago

Yes, it's a bug. Thanks for the report. I'll see to it presently.

MikeMcl commented 1 year ago

Fixed in v9.1.1.