1.0.0 • Public • Published


How to work with Big numbers

One of the issues that we face when working with big numbers is mathematical operations. Specially in Javascript, it gives us the wrong result for any math operations on a number bigger than 9007199254740991.

This file will make us to do all the main mathematics operation by making the numbers into strings and works with strings.

Different methods

There is a class named MathOperation which can be used to do the operations.

  • numberToStringInSlots:

    To get a number and make each digit in a slot.

  • slotsSum:

    To get the sum of all digits.

  • dividedBy2:

    To check if a number is a factor of number 2.

  • dividedBy3:

    To check if a number is a factor of number 3.

  • dividedBy6:

    To check if a number is a factor of number 6.

  • max:

    To get the maximum between two numbers.

  • min:

    To get the minimum between two numbers.

  • add:

    To add two numbers.

  • subtract:

    To subtract two numbers.

  • multiply:

    To multiply two numbers.

  • cross:

    To multiply two numbers. / this is another way.

  • division:

    To divide two numbers./ The result will be an array. The first element is the Math.floor of that division and the second elemenet is the residual of that.

  • sqrtFloor:

    To Find the Math.floor(Math.sqrt) of a number.

  • power:

    To power a number by another number.

  • residual:

    To Find the residual of a division between two numbers.

  • The numbers should be in string type.




npm i math-operation-js

DownloadsWeekly Downloads






Unpacked Size

16.7 kB

Total Files


Last publish


  • farid.masjedi