SlideShare a Scribd company logo
BigInt: Integers as
big as you want in
JavaScript
Daniel Ehrenberg
Igalia
In partnership with Bloomberg
Web Engines Hackfest 2017
Why add something?
● Represent bigger Integers:
● inode numbers
● Microseconds since the Unix epoch
● Hashes/checksums
● FFIs to languages with larger integer types
● Basis for users implementing a Decimal type
● Manipulate binary data containing 64-bit ints
● Project Euler...
What would make sense in JS?
● Sadness: 1 is 1.0
○ Resolution: Use 1n for integers
● Sadness: 12374699872164983276428373n + 1 = ?
○ Resolution: Throw a TypeError
● Sadness: Entire ecosystem is based on Numbers
○ Resolution: Throw more TypeErrors
● Sadness: Number means float, so we can’t call it BigNum
○ Resolution: BigInt!
Add BigInt or Int64?
● For Int64
○ Most programmer requests fit in this range (or
Uint64)
○ Programmers assume Int64 will be faster
● For BigInt
○ Overflowing is usually a bug
○ High-level dynamic languages usually opt for BigInt
○ If we don’t do BigInt, need multiple size types
○ BigInt.asIntN/asUintN provides overflow
○ Implementers say BigInt should be fast
● Resolution: BigInt
Enter TC39
● JavaScript standards committee
● Meets every two months
● Representatives from
○ Browser vendors
○ JavaScript programmers
○ Framework/library authors
○ Language experts
○ Node.js
● Current draft spec at https://tc39.github.io/ecma262/
History of Int64/BigInt in TC39
● ES1 has only Number--double float
● Integer types in Waldemar Horwat’s ES2 proposal (1999)
● ES2, ES3 are editorial/library changes
● Proposed for ES4 (~2004-2008) -- abandoned
● ES5, ES5.1 is intentionally minimal
● ES6 proposed “value types” -- deferred
● November 2016, Brendan Eich proposes Int64/Uint64
TC39 Stage process
● Stage 1: An idea in a GitHub repo
● Stage 2: Committee supports initial draft
● Stage 3: Solid draft resolving all committee concerns
● Stage 4: Two implementations and conformance tests;
joins the spec working draft
● In the background: Annually, annual official versions
declared, for “reasons”
History of Int64/BigInt in TC39
● November 2016, Brendan Eich proposes Int64/Uint64
○ Stage 1!
● V8 team proposes BigInt rather than Int64
● January 2017, agreement on change to BigInt
● March 2017, BigInt to Stage 2
● May 2017, gradually work out more spec issues
● July 2017, BigInt to Stage 3
● Draft BigInt spec
Meanwhile, in code...
● Implementations in progress in
○ SpiderMonkey
○ V8
○ Babel polyfill
● Conformance tests (test262) in progress
● Other browsers expressed interest
● My prediction: Usable in multiple browsers next year
Questions?
● TC39 heckling welcome

More Related Content

PDF
Asyncio : Final frontier in python
PPTX
Running of nist test
PPTX
Lecture02
PPT
C to C++ Migration Strategy
PDF
BigInts In JavaScript: A Case Study In TC39 (JSConf EU 2018)
PPTX
Data Wars: The Bloody Enterprise strikes back
PDF
BigDecimal: Avoid rounding errors on decimals in JavaScript (Node.TLV 2020)
PDF
Asyncio : Final frontier in python
Running of nist test
Lecture02
C to C++ Migration Strategy
BigInts In JavaScript: A Case Study In TC39 (JSConf EU 2018)
Data Wars: The Bloody Enterprise strikes back
BigDecimal: Avoid rounding errors on decimals in JavaScript (Node.TLV 2020)

Similar to BigInt: Integers as big as you want in JavaScript (Web Engines Hackfest 2017) (20)

PDF
Big Decimal: Avoid Rounding Errors on Decimals in JavaScript
PDF
TC39: How we work, what we are working on, and how you can get involved (dotJ...
PDF
Lagergren jvmls-2013-final
PDF
Next Generation Indexes For Big Data Engineering (ODSC East 2018)
PDF
BINARY DATA ADVENTURES IN BROWSER JAVASCRIPT
PDF
Basic data structure DATA STRUCTURE ALGORITHM
PDF
Data types
PDF
(6) cpp numeric representation
PPT
Binary
PPTX
3 JavaScript challenges for one application
PPTX
Lesson4.2 u4 l1 binary squences
PDF
How big is your data
PPTX
Bitwise Operations in Programming
PPT
Topic 1 Data Representation
PPT
Topic 1 Data Representation
PDF
Nitty Gritty of Data Serialisation
PPTX
MiamiJS - The Future of JavaScript
PPTX
Data types in java | What is Datatypes in Java | Learning with RD | Created b...
PPT
cprogrammingdatatypesand differentdtatypes (1).ppt
PPT
cprogrammingdatatype using clangauge(1).ppt
Big Decimal: Avoid Rounding Errors on Decimals in JavaScript
TC39: How we work, what we are working on, and how you can get involved (dotJ...
Lagergren jvmls-2013-final
Next Generation Indexes For Big Data Engineering (ODSC East 2018)
BINARY DATA ADVENTURES IN BROWSER JAVASCRIPT
Basic data structure DATA STRUCTURE ALGORITHM
Data types
(6) cpp numeric representation
Binary
3 JavaScript challenges for one application
Lesson4.2 u4 l1 binary squences
How big is your data
Bitwise Operations in Programming
Topic 1 Data Representation
Topic 1 Data Representation
Nitty Gritty of Data Serialisation
MiamiJS - The Future of JavaScript
Data types in java | What is Datatypes in Java | Learning with RD | Created b...
cprogrammingdatatypesand differentdtatypes (1).ppt
cprogrammingdatatype using clangauge(1).ppt

More from Igalia (20)

PDF
Life of a Kernel Bug Fix
PDF
Unlocking the Full Potential of WPE to Build a Successful Embedded Product
PDF
Advancing WebDriver BiDi support in WebKit
PDF
Jumping Over the Garden Wall - WPE WebKit on Android
PDF
Collective Funding, Governance and Prioritiation of Browser Engine Projects
PDF
Don't let your motivation go, save time with kworkflow
PDF
Solving the world’s (localization) problems
PDF
The Whippet Embeddable Garbage Collection Library
PDF
Nobody asks "How is JavaScript?"
PDF
Getting more juice out from your Raspberry Pi GPU
PDF
WebRTC support in WebKitGTK and WPEWebKit with GStreamer: Status update
PDF
Demystifying Temporal: A Deep Dive into JavaScript New Temporal API
PDF
CSS :has() Unlimited Power
PDF
Device-Generated Commands in Vulkan
PDF
Current state of Lavapipe: Mesa's software renderer for Vulkan
PDF
Vulkan Video is Open: Application showcase
PDF
Scheme on WebAssembly: It is happening!
PDF
EBC - A new backend compiler for etnaviv
PDF
RISC-V LLVM State of the Union
PDF
Device-Generated Commands in Vulkan
Life of a Kernel Bug Fix
Unlocking the Full Potential of WPE to Build a Successful Embedded Product
Advancing WebDriver BiDi support in WebKit
Jumping Over the Garden Wall - WPE WebKit on Android
Collective Funding, Governance and Prioritiation of Browser Engine Projects
Don't let your motivation go, save time with kworkflow
Solving the world’s (localization) problems
The Whippet Embeddable Garbage Collection Library
Nobody asks "How is JavaScript?"
Getting more juice out from your Raspberry Pi GPU
WebRTC support in WebKitGTK and WPEWebKit with GStreamer: Status update
Demystifying Temporal: A Deep Dive into JavaScript New Temporal API
CSS :has() Unlimited Power
Device-Generated Commands in Vulkan
Current state of Lavapipe: Mesa's software renderer for Vulkan
Vulkan Video is Open: Application showcase
Scheme on WebAssembly: It is happening!
EBC - A new backend compiler for etnaviv
RISC-V LLVM State of the Union
Device-Generated Commands in Vulkan

Recently uploaded (20)

PDF
Approach and Philosophy of On baking technology
PPT
Teaching material agriculture food technology
PPTX
Spectroscopy.pptx food analysis technology
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Empathic Computing: Creating Shared Understanding
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
cuic standard and advanced reporting.pdf
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
Spectral efficient network and resource selection model in 5G networks
PPTX
Big Data Technologies - Introduction.pptx
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Network Security Unit 5.pdf for BCA BBA.
Approach and Philosophy of On baking technology
Teaching material agriculture food technology
Spectroscopy.pptx food analysis technology
Review of recent advances in non-invasive hemoglobin estimation
Empathic Computing: Creating Shared Understanding
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
cuic standard and advanced reporting.pdf
Digital-Transformation-Roadmap-for-Companies.pptx
Programs and apps: productivity, graphics, security and other tools
Chapter 3 Spatial Domain Image Processing.pdf
gpt5_lecture_notes_comprehensive_20250812015547.pdf
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Assigned Numbers - 2025 - Bluetooth® Document
NewMind AI Weekly Chronicles - August'25-Week II
MIND Revenue Release Quarter 2 2025 Press Release
Spectral efficient network and resource selection model in 5G networks
Big Data Technologies - Introduction.pptx
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Network Security Unit 5.pdf for BCA BBA.

BigInt: Integers as big as you want in JavaScript (Web Engines Hackfest 2017)

  • 1. BigInt: Integers as big as you want in JavaScript Daniel Ehrenberg Igalia In partnership with Bloomberg Web Engines Hackfest 2017
  • 2. Why add something? ● Represent bigger Integers: ● inode numbers ● Microseconds since the Unix epoch ● Hashes/checksums ● FFIs to languages with larger integer types ● Basis for users implementing a Decimal type ● Manipulate binary data containing 64-bit ints ● Project Euler...
  • 3. What would make sense in JS? ● Sadness: 1 is 1.0 ○ Resolution: Use 1n for integers ● Sadness: 12374699872164983276428373n + 1 = ? ○ Resolution: Throw a TypeError ● Sadness: Entire ecosystem is based on Numbers ○ Resolution: Throw more TypeErrors ● Sadness: Number means float, so we can’t call it BigNum ○ Resolution: BigInt!
  • 4. Add BigInt or Int64? ● For Int64 ○ Most programmer requests fit in this range (or Uint64) ○ Programmers assume Int64 will be faster ● For BigInt ○ Overflowing is usually a bug ○ High-level dynamic languages usually opt for BigInt ○ If we don’t do BigInt, need multiple size types ○ BigInt.asIntN/asUintN provides overflow ○ Implementers say BigInt should be fast ● Resolution: BigInt
  • 5. Enter TC39 ● JavaScript standards committee ● Meets every two months ● Representatives from ○ Browser vendors ○ JavaScript programmers ○ Framework/library authors ○ Language experts ○ Node.js ● Current draft spec at https://tc39.github.io/ecma262/
  • 6. History of Int64/BigInt in TC39 ● ES1 has only Number--double float ● Integer types in Waldemar Horwat’s ES2 proposal (1999) ● ES2, ES3 are editorial/library changes ● Proposed for ES4 (~2004-2008) -- abandoned ● ES5, ES5.1 is intentionally minimal ● ES6 proposed “value types” -- deferred ● November 2016, Brendan Eich proposes Int64/Uint64
  • 7. TC39 Stage process ● Stage 1: An idea in a GitHub repo ● Stage 2: Committee supports initial draft ● Stage 3: Solid draft resolving all committee concerns ● Stage 4: Two implementations and conformance tests; joins the spec working draft ● In the background: Annually, annual official versions declared, for “reasons”
  • 8. History of Int64/BigInt in TC39 ● November 2016, Brendan Eich proposes Int64/Uint64 ○ Stage 1! ● V8 team proposes BigInt rather than Int64 ● January 2017, agreement on change to BigInt ● March 2017, BigInt to Stage 2 ● May 2017, gradually work out more spec issues ● July 2017, BigInt to Stage 3 ● Draft BigInt spec
  • 9. Meanwhile, in code... ● Implementations in progress in ○ SpiderMonkey ○ V8 ○ Babel polyfill ● Conformance tests (test262) in progress ● Other browsers expressed interest ● My prediction: Usable in multiple browsers next year