PowiainaNum.js

A large number library reaching {10,9e15,1,1,1,2} in Bower's operator notation.

For smaller numbers, use other libraries such as:

How it works

This library works by storing the sign, layer, and an array.
The sign is either 1 or -1, positive or negative respectively.
Array holds small part of the magnitude; It can be respented in TypeScript:

type PowiainaNumArray = {
    arrow: number,
    expans: number,
    megota: number,
    repeat: number,
}[]
      

In PowiainaNum.js 0.1.x version, it was
[number, ...([number|"x", number, number|"x", number])[]]
      

Codes

Importing this project

Use this HTML code to import this project below.

<script type="importmap">
{
    "imports": {
        "powiaina_num.js": "./dist/PowiainaNum.esm.js" // change ./dist/PowiainaNum.esm.js path, and remove this // comment
    }
}
</script>
<script type="module">
    import PowiainaNum from 'powiaina_num.js';
    window.PowiainaNum = PowiainaNum
</script>
      

Or use:

<script src="PowiainaNum.js"></script>
<script>PowiainaNum = PowiainaNum.default</script>

Create a PowiainaNum.js Class

How can we convert a javascript number type(will be abbr.ed as purenum) to a PowiainaNum.js class(PN.js cls)?

Use this code below to create PN.js cls with purenum 3:

var num = new PowiainaNum(3);
var num2 = new PowiainaNum(6);

I calculate num1 + num2, but it says '36', why?

You should use num1.add(num2) instead of num1+ num2.

num1.add(num2) returns a new PN.js cls that is the sum of num1 & num2.

Also, replace a-b to a.sub(b), a*b to a.mul(b), a^b to a.pow(b).

More functions see this link