Live data from Hacker News

A Million Digits of Pi in 9 Lines of JavaScript

ajennings.net

1–10 of 86 posts

Re: A Million Digits of Pi in 9 Lines of JavaScript

#5
post #3

Wow, I wonder why Firefox is so much slower? Quantum seems pretty zippy overall, but maybe that's largely due to fast rendering speeds? Does anyone on the Spidermonkey team have some insight?

Looks like they are using big integers, which I'd guess isn't something that comes up a lot, so probably hasn't been optimized for too much.

Re: A Million Digits of Pi in 9 Lines of JavaScript

#6

What is the actual equation? They just list the first couple of terms.

Good question. I just presented it here the way it was given to me, as a couple initial terms and some rules on how it evolves, because I find that to be the easiest way to remember it.

The actual formula looks much less friendly (because it's tricky to write "the product of the first n odd integers"), but it's a good exercise for those who are inclined.

Re: A Million Digits of Pi in 9 Lines of JavaScript

#7

What is the actual equation? They just list the first couple of terms.

The article says: let i = 1n; let x = 3n * (10n 1000020n); let pi = x; while (x > 0) { x = x * i / ((i + 1n) * 4n); pi += x / (i + 2n); i += 2n; } console.log(pi / (10n 20n));

Re: A Million Digits of Pi in 9 Lines of JavaScript

#10
post #3

Wow, I wonder why Firefox is so much slower? Quantum seems pretty zippy overall, but maybe that's largely due to fast rendering speeds? Does anyone on the Spidermonkey team have some insight?

https://bugzilla.mozilla.org/show_bug.cgi?id=1366287

The open issues this bug depends on is a pretty good list of bigint-related performance enhancements that haven't been implemented yet.

Post reply on HN