naruyoko / expantanum.js Goto Github PK
View Code? Open in Web Editor NEWA JavaScript library that handles arithmetic for numbers as large as {10,9e15,1,2}.
Home Page: https://naruyoko.github.io/ExpantaNum.js/index.html
License: MIT License
A JavaScript library that handles arithmetic for numbers as large as {10,9e15,1,2}.
Home Page: https://naruyoko.github.io/ExpantaNum.js/index.html
License: MIT License
ExpantaNum('10^^1e30').toString()
yields '10^^10^1e30'
not '10^^1e30'
To reproduce:
return ExpantaNum.arrow(3, 3, 3)
1670044697132ms, 23:18:17 GMT-0600 (Central Standard Time)
ReferenceError: OmegaNum is not defined
ReferenceError: OmegaNum is not defined
at eval (eval at <anonymous> (https://naruyoko.github.io/ExpantaNum.js/test.js:102:12), <anonymous>:938:32)
at Q.arrow (eval at <anonymous> (https://naruyoko.github.io/ExpantaNum.js/test.js:102:12), <anonymous>:956:38)
at eval (eval at dg.onclick (https://naruyoko.github.io/ExpantaNum.js/test.js:7:51), <anonymous>:3:19)
at dg.onclick (https://naruyoko.github.io/ExpantaNum.js/test.js:7:99)
Likely caused by this commit: d96a3cb
10^10^10^10^10^10^10^10^NaN
Reproduction Steps:
ExpantaNum.ZERO.toStringWithDecimalPlaces(3,true)
raises the following error:
Uncaught RangeError: toFixed() digits argument must be between 0 and 100
at Number.toFixed (<anonymous>)
at decimalPlaces (eval at <anonymous> (test.js:102:12), <anonymous>:1213:31)
at P.toStringWithDecimalPlaces (eval at <anonymous> (test.js:102:12), <anonymous>:1250:28)
at <anonymous>:1:17
This works in the console on https://naruyoko.github.io/ExpantaNum.js/test.html, and also still errors when replacing 3
with any other integer.
Input: ExpantaNum.pent(0,2) // 0^^^2
Output: NaN
Input: ExpantaNum.pent(0,Infinity) // 0^^^Infinity
Output: Infinity
This should be (10^^)^22 (10^)^150 153.15327796708874 for correct calculation or (10^^)^22 (10^)^75 153.15327796708874 for correct display
When running:
ExpantaNum.lambertw("ee4992767175317001")
ExpantaNum.js
errors out with the following:
Uncaught Error: Iteration failed to converge: e1e4992767175317001
d_lambertw@https://naruyoko.github.io/ExpantaNum.js/test.js line 102 > Function:673:11
anonymous/P.lambertw@https://naruyoko.github.io/ExpantaNum.js/test.js line 102 > Function:688:51
anonymous/Q.lambertw@https://naruyoko.github.io/ExpantaNum.js/test.js line 102 > Function:692:30
anonymous@https://naruyoko.github.io/ExpantaNum.js/test.js line 7 > Function:3:19
@https://naruyoko.github.io/ExpantaNum.js/test.js:7:99
See also Patashu/break_eternity.js#152.
When the library standardizes numbers such as [[0, a],[1, x], ...] (x is bigger than the max safe integer), it crashes on line 1165, x.splice(1,i);
.
I hope the bug will be fixed soon.
ExpantaNum.fromString("1.000F10")
// Malformed input: 1.000F10
ExpantaNum.HyperE("1.000F10")
// Malformed input: 1.000F10
Seems like this line:
Line 42 in 49b1fc5
needs to include [E-Ze]+
(or whatever the max range is):
- isExpantaNum = /^[-\+]*(Infinity|NaN|(J+|J\^\d+ )?(10(\^+|\{[1-9]\d*\})|\(10(\^+|\{[1-9]\d*\})\)\^[1-9]\d* )*((\d+(\.\d*)?|\d*\.\d+)?([Ee][-\+]*))*(0|\d+(\.\d*)?|\d*\.\d+))$/,
+ isExpantaNum = /^[-\+]*(Infinity|NaN|(J+|J\^\d+ )?(10(\^+|\{[1-9]\d*\})|\(10(\^+|\{[1-9]\d*\})\)\^[1-9]\d* )*((\d+(\.\d*)?|\d*\.\d+)?([E-Ze]+[-\+]*))*(0|\d+(\.\d*)?|\d*\.\d+))$/,
^^^^^^^
And it seems like that works now:
isExpantaNum.test("1.000e10")
// true
isExpantaNum.test("1.000e10e25")
// true
isExpantaNum.test("1.000F10")
// true
isExpantaNum.test("Ge1.025e52")
// true
isExpantaNum.test("1.00FF125")
// true
isExpantaNum.test("1.00A125e25")
// false
However, it doesn't parse the strings correctly still, just doesn't say it's malformed input.
fromHyperE
looks to use a similar regex, but not isExpantaNum
, I'm not sure what that's for.
I created a PR with jest tests to demonstrate the issue: #24
> ExpantaNum.pent("(10^^)^5 288",41.1)
< '(10^^)^42 (10^)^286 10000000000'
> ExpantaNum.pent("(10^^)^5 288",41)
< '(10^^)^44 (10^)^286 10000000000'
The first result should be bigger than the second result.
is there a function that I haven't seen that let's you use hyperoperations larger than tetration and pentation?
1.5
in new ExpantaNum("J1.5")
can be replaced by any positive decimal number and it will still result in a hang.P.standardize
function.ExpantaNum.maxOps
to 10 didn't help much.ExpantaNum(2).factorial.toString();
"function (){\n var x=this.clone();\n var f=ExpantaNum.factorials;\n if (x.lt(ExpantaNum.ZERO)||!x.isint()) return x.add(1).gamma();\n if (x.lte(170)) return new ExpantaNum(f[+x]);\n var errorFixer=1;\n var e=+x;\n if (e<500) e+=163879/209018880Math.pow(e,5);\n if (e<1000) e+=-571/2488320Math.pow(e,4);\n if (e<50000) e+=-139/51840Math.pow(e,3);\n if (e<1e7) e+=1/288Math.pow(e,2);\n if (e<1e20) e+=1/12*e;\n return x.div(ExpantaNum.E).pow(x).mul(x.mul(ExpantaNum.PI).mul(2).sqrt()).times(errorFixer);\n }"
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.