Giter Club home page Giter Club logo

expantanum.js's People

Contributors

naruyoko avatar reinhardt-c avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

expantanum.js's Issues

`ExpantaNum.arrow(3, 3, 3)` throws `ReferenceError: OmegaNum is not defined`

To reproduce:

  1. Open https://naruyoko.github.io/ExpantaNum.js/test.html
  2. In the code to be executed, input return ExpantaNum.arrow(3, 3, 3)
  3. Leave the version at the default.
  4. Click "Run".
  5. Stderr output:
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

toStringWithDecimalPlaces throws RangeError on zero

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.

`ExpantaNum.lambertw("ee4992767175317001")` throws an error

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.

Max Safe Integer

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.

fromString() (or fromHyperE()?) don't parse larger string numbers

ExpantaNum.fromString("1.000F10")
// Malformed input: 1.000F10

ExpantaNum.HyperE("1.000F10")
// Malformed input: 1.000F10

Seems like this line:

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+))$/,

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

Pentation

> 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.

new ExpantaNum("J1.5") hangs the script

  • The 1.5 in new ExpantaNum("J1.5") can be replaced by any positive decimal number and it will still result in a hang.
  • The hang occurs in the P.standardize function.
  • Reducing ExpantaNum.maxOps to 10 didn't help much.

i used factorial and toString() and got this result

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 }"

image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.