bigint shipping in firefox!

23 May 2019 12:13 PM (compilers | bigint | bignums | javascript | firefox | spidermonkey | v8 | igalia | bloomberg)

I am delighted to share with folks the results of a project I have been helping out on for the last few months: implementation of "BigInt" in Firefox, which is finally shipping in Firefox 68 (beta).

what's a bigint?

BigInts are a new kind of JavaScript primitive value, like numbers or strings. A BigInt is a true integer: it can take on the value of any finite integer (subject to some arbitrarily large implementation-defined limits, such as the amount of memory in your machine). This contrasts with JavaScript number values, which have the well-known property of only being able to precisely represent integers between -253 and 253.

BigInts are written like "normal" integers, but with an n suffix:

var a = 1n;
var b = a + 42n;
b << 64n
// result: 793209995169510719488n

With the bigint proposal, the usual mathematical operations (+, -, *, /, %, <<, >>, **, and the comparison operators) are extended to operate on bigint values. As a new kind of primitive value, bigint values have their own typeof:

typeof 1n
// result: 'bigint'

Besides allowing for more kinds of math to be easily and efficiently expressed, BigInt also allows for better interoperability with systems that use 64-bit numbers, such as "inodes" in file systems, WebAssembly i64 values, high-precision timers, and so on.

You can read more about the BigInt feature over on MDN, as usual. You might also like this short article on BigInt basics that V8 engineer Mathias Bynens wrote when Chrome shipped support for BigInt last year. There is an accompanying language implementation article as well, for those of y'all that enjoy the nitties and the gritties.

can i ship it?

To try out BigInt in Firefox, simply download a copy of Firefox Beta. This version of Firefox will be fully released to the public in a few weeks, on July 9th. If you're reading this in the future, I'm talking about Firefox 68.

BigInt is also shipping already in V8 and Chrome, and my colleague Caio Lima has an project in progress to implement it in JavaScriptCore / WebKit / Safari. Depending on your target audience, BigInt might be deployable already!


I must mention that my role in the BigInt work was relatively small; my Igalia colleague Robin Templeton did the bulk of the BigInt implementation work in Firefox, so large ups to them. Hearty thanks also to Mozilla's Jan de Mooij and Jeff Walden for their patient and detailed code reviews.

Thanks as well to the V8 engineers for their open source implementation of BigInt fundamental algorithms, as we used many of them in Firefox.

Finally, I need to make one big thank-you, and I hope that you will join me in expressing it. The road to ship anything in a web browser is long; besides the "simple matter of programming" that it is to implement a feature, you need a specification with buy-in from implementors and web standards people, you need a good working relationship with a browser vendor, you need willing technical reviewers, you need to follow up on the inevitable security bugs that any browser change causes, and all of this takes time. It's all predicated on having the backing of an organization that's foresighted enough to invest in this kind of long-term, high-reward platform engineering.

In that regard I think all people that work on the web platform should send a big shout-out to Tech at Bloomberg for making BigInt possible by underwriting all of Igalia's work in this area. Thank you, Bloomberg, and happy hacking!

20 responses

  1. Grungoid says:

    censoring my comment will not resolve the inherent dishonesty of this article!!!

  2. Tom Theisen says:

    @Grungoid: Here's some corroborating information that seems to substantiate the claim that bigint will ship in FF68.

  3. Grungoid says:

    Thank you Tom, I was mistaken about the article!! have a great day

  4. Awkii says:

    "I was wrong thanks, bye"

    This is the first time I've ever heard this on the internet

  5. Marc says:

    Why is it 2^53? I would expect 2^63 (64 bit and one bit signed/unsigned).

  6. Craig says:

    @Marc because JavaScript numbers are represented as doubles (64 bit floating-point numbers), which only have 52 bits of precision. The exponent and the sign bit occupy the other 12.

    It was the same way in Lua, until they added a split float/integer representation in 5.3. A lot of times all you really need is the full 64 bits of an integer instead of BigInts.

  7. mobile detailing Orlando says:

    Sounds interesting enough; maybe I'll watch out for this.

  8. Windows Error Code 0x80070035 says:

    I like your blog post. Keep on writing this type of great stuff. I make sure to follow up on your blog in the future. Thanks for sharing such types of information.

  9. Digital Marketing Services in Delhi says:

    I took away a lot very good points from this post and will definitely save it in my bookmarks. Thanks for the effort you took to elaborate on this subject so thoroughly.

  10. gamcore says:

    his type of great stuff. I make sure to follow up on your blog in the fut

  11. Walter Allen says:

    However small your role might have been, you've certainly contributed to a major project in the tech space. Cheers to you!

  12. Jermaine Alfred says:

    So proud of you for your achievement plus your dissection of this feature is excellent. I couldn't ask for anything more.

  13. AT&T Email Not Working says:

    I took away a lot very good points from this post and will definitely save it in my bookmarks. Thanks for the effort you took to elaborate on this subject so thoroughly. I look forward to future posts.

  14. kasautii zindagii kay says:

    Thanks for updating his quality stuff.. Apreciated your work

  15. Dmytro Donskoy says:

    Firefox is my favourite!

  16. <a href=""></a> says:

    Congratulations! Good for you. Whether your role is small or big but the fact that you have a contribution, you still deserve it. We will definitely try it out.

  17. says:

    I like using Firefox as browser becuase it is fast.

  18. Click here says:

    Great article, I unfortunately had some problems printing this article out, The print formatting looks a little screwed over, something you might want to look into.

  19. impossible game says:

    My friend gave me the right advice, thank you for your sharing, it gives me more information

  20. hoster pak says:

    Hello is it free for life or only trial version available of this addon for firefox and secondly is it supported by the current version of firefox or we have to download the old version of firefox for it to work.

Leave a Reply