Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't convert BigInt to OmegaNum without returning NaN or Infinity #37

Closed
James103 opened this issue Jan 11, 2023 · 3 comments
Closed

Comments

@James103
Copy link

James103 commented Jan 11, 2023

Currently (release 0.5.7), attempting to convert a BigInt value to OmegaNum will return either NaN if the BigInt is being passed in directly or Infinity if the BigInt (whose value is bigger than 21024) is converted to a string which is then passed into the OmegaNum constructor.

new OmegaNum(1234n).toString()
'NaN'

new OmegaNum(2n**1234n).toString()
'NaN'

new OmegaNum(String(1234n)).toString()
'1234'

new OmegaNum(String(2n**1234n)).toString()
'Infinity'

The expected output should be 1234 for the 1234n test case and approximately 2.958112e371 for the 2n**1234n test case.

Naruyoko added a commit to Naruyoko/ExpantaNum.js that referenced this issue Jan 23, 2023
@James103
Copy link
Author

The test works as expected in all four cases in both OmegaNum.js and ExpantaNum.js.
Even a string solely consisting of a million 1 digits converts properly (up to precision limitations).

@jakub791
Copy link

But that has nothing to do with BigInt?

@James103
Copy link
Author

For similar effect, I can construct a BigInt whose value is 9n ** 1048576n and pass it into the OmegaNum (or ExpantaNum) constructor and it will still work and give the expected output (6.216956799074759e1000595).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants