Suggestion-Box icon indicating copy to clipboard operation
Suggestion-Box copied to clipboard

Creating a Javascript to do math on huge numbers.

Open Denmarks opened this issue 1 year ago • 2 comments

The largest number that JavaScript can handle is 9007199254740991. Years ago I had a personal website and created a script to do addition, subtraction, multiplication, and division on practically unlimited size positive integers. I do one column at a time like someone doing it on paper. I still have the script and wonder if it would be a good challenge. Details on request.

Denmarks avatar May 19 '23 21:05 Denmarks

Aren't their existing libraries available like bigint

Vanshika-Dargan avatar Aug 12 '23 12:08 Vanshika-Dargan

There are libraries but there are for a lot of things Coding Train covers, it's not about doing it better but rather about showing how such things work so people understand them.

There's a weird but kinda awesome algorithm to double the precision of floating point numbers that could be coded up in JS

https://www.youtube.com/watch?v=6OuqnaHHUG8

it's kind of better than going column by column and I'm sure it could be extended to arbitrary precision (possibly by recursion)

Doing it as part of a series like 'build your own calculator' would be kind of awesome

JohnyDL avatar Aug 18 '23 13:08 JohnyDL