DEV Community

Gaurav Singh
Gaurav Singh

Posted on

World most powerful math function!

subtraction including larger digits

Adding, subtraction, multiplication and division for long digit in JavaScript may not give correct answer.

So, I create math function solve those problem.

Here you can try this codepen: https://codepen.io/gauravnumber/pen/RwLaePQ

Source code of repo here:
https://github.com/gauravnumber/math-code

Currently math-code support addition, subtraction, multiplication, divison, <, >, <=, >=, =, !=

Floating digit also.
You can multiply 30, 50 digit using decimal number with high accuracy.

Discussion (4)

Collapse
jonrandy profile image
Jon Randy • Edited on

Javascript can natively handle integers like this just fine with BigInts:

12344445561899921212212323323n - 556273382382776626287828267622n
// -543928936820876705075615944299n
Enter fullscreen mode Exit fullscreen mode
Collapse
gauravnumber profile image
Gaurav Singh Author

But in math-code you can solve 500 digit number also.

Collapse
vermamayank564 profile image
vermamayank564

Tell me your terminal configuration bro?

Collapse
gauravnumber profile image
Gaurav Singh Author

I use zsh shell with ohmyzsh framework added zsh-autocomplete plugin