archives

JavaScript in the browser : (yet another) bigint calculator toy language

Hi,

I was curious to see how JavaScript in my various browser versions is performing lately in the case of both stack-greedy and numeric operations-intensive computations (well, or somehow).

So I made this small big integer-calculator toy language (three keywords only : const, print, and show) providing the usual four operations, the modulus (%), and four builtin functions: the square root (sqrt), the power (pow), the recursive factorial (fact) and a memoizing Fibonacci (fibo).

(the language isn't just a fluent interface hosted by JavaScript; it's parsed by an actual PEG-based parser I made after augmenting Chris Double's jsparse a bit for my needs.)

The results (timings) and differences observed are sometimes interesting.

EDIT:
1. the calculator also knows the first 20 Mersenne primes (consts M1 thru M20); e.g.:

show M20 ;

2. the semicolon is a statement terminator, not a separator
3. no parse error handling at all