# npm

## bestmath

1.1.1 • Public • Published

# bettermath

## introduction

the safer integer in js is 9007199254740991.

we can see this number big but I was limited for my RSA system. So I've reinvent the number in js: number are array. Each numberarray are compose like this

```// realnumber:
let mynum = 23
// arraynumber:
let mynum = [3,2]```

the number are reverst because it's more easier to manipuling this. But don't worry using the transform and intoString methods you havn't to read inverse Array of number

## example

```const bmath = require("bettermath")
let num1 = bmath.transform(9007199254740991)
let num2 = bmath.add(num1, bmath.transform(1) /* or [1]*/)
console.log(bmath.intoString(num2)) // return 9007199254740992
console.log(bmath.isEqual(num1, num2)) // return false```

## docs

### .transform

return a Array

transform number in to Array ex:

`bmath.transform(45) // return [5, 4]`

return an Array

`bmath.add([5, 4], (5, 4)) // returnn [0, 9]`

### .intoString

return a String

transform Arraynumber in String ex:

`bmath.intoString([5, 4])// return 45`

### .intoNumber

exactly like intoString but it's return Number can be NaN and Infinite

### .isInferieur .isSuperieur .isEqual

for compare to Arraynumber

return boolean ex:

`bmath.isEqual([5, 4],[5, 4]) // return true`

### .reduce

reduce Arraynumber with 0 useless

return an Array

`bmath.reduce([1,0]) // return [1]`

### .sub

substract 2 Arraynumber

return an Array ex:

`bmath.sub([5, 4], [1]) // return [4, 4]`

### .mul

multiply 2 Arraynumber

return an Array ex:

`bmat.mul([2],[3]) // return 6`

### .div

divide to number (euclidienne)

return an object like this `{result:[x], modulo:[x]}` ex:

`bmat.div([4],[3]) // return {result: [1], modulo:[1]}`

# WARNING this project accept juste positive and not comma number

if you want to add somthing to the project go on github and good luck because this are brainfuck.

## Keywords

### Install

`npm i bestmath`

### Repository

github.com/leblanmonster/bettermath

4

1.1.1

MIT

10.1 kB

4