Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Ecmascript BigInt
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Taketoshi Aono(青野健利 a.k.a brn)
August 24, 2017
Programming
3
590
Ecmascript BigInt
Ecmascript で導入されそうなBigInt型についてです。
Taketoshi Aono(青野健利 a.k.a brn)
August 24, 2017
Tweet
Share
More Decks by Taketoshi Aono(青野健利 a.k.a brn)
See All by Taketoshi Aono(青野健利 a.k.a brn)
document.write再考
brn
6
3.1k
Parsing Javascript
brn
14
9.4k
JSON & Object Tips
brn
1
540
CA 1Day Youth Bootcamp for Frontend LT
brn
0
1k
Modern TypeScript
brn
2
850
javascript - behind the scene
brn
3
790
tc39 proposals
brn
0
940
プロダクト開発とTypeScript
brn
8
3k
React-Springでリッチなアニメーション
brn
1
750
Other Decks in Programming
See All in Programming
AI時代の認知負荷との向き合い方
optfit
0
150
SourceGeneratorのススメ
htkym
0
190
AtCoder Conference 2025
shindannin
0
1k
AI巻き込み型コードレビューのススメ
nealle
0
120
コマンドとリード間の連携に対する脅威分析フレームワーク
pandayumi
1
450
カスタマーサクセス業務を変革したヘルススコアの実現と学び
_hummer0724
0
630
AI前提で考えるiOSアプリのモダナイズ設計
yuukiw00w
0
220
CSC307 Lecture 06
javiergs
PRO
0
680
CSC307 Lecture 07
javiergs
PRO
0
550
Package Management Learnings from Homebrew
mikemcquaid
0
200
フルサイクルエンジニアリングをAI Agentで全自動化したい 〜構想と現在地〜
kamina_zzz
0
400
Apache Iceberg V3 and migration to V3
tomtanaka
0
150
Featured
See All Featured
GraphQLとの向き合い方2022年版
quramy
50
14k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
37
6.3k
Making the Leap to Tech Lead
cromwellryan
135
9.7k
Jamie Indigo - Trashchat’s Guide to Black Boxes: Technical SEO Tactics for LLMs
techseoconnect
PRO
0
55
Heart Work Chapter 1 - Part 1
lfama
PRO
5
35k
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
11
820
Have SEOs Ruined the Internet? - User Awareness of SEO in 2025
akashhashmi
0
270
Navigating Team Friction
lara
192
16k
How to optimise 3,500 product descriptions for ecommerce in one day using ChatGPT
katarinadahlin
PRO
0
3.4k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
35
3.3k
Raft: Consensus for Rubyists
vanstee
141
7.3k
Jess Joyce - The Pitfalls of Following Frameworks
techseoconnect
PRO
1
63
Transcript
Ecmascript BigInt
せ: @brn (ꫬꅿ⨳ⵃa.k.a ـٕ٦ظ) 耵噟: ؿٗٝزؒٝسؒٝآص،٥iOSؒٝآص، ⠓爡: Cyberagent ،سذؙأةآؔRightSegment٥AI Messenger
ـؚٗ: http://abcdef.gets.b6n.ch/ Twitter: https://twitter.com/brn227 GitHub: https://github.com/brn
Integer or Number… JavascriptךNumber㘗כ⦓侧䏝㼭侧挿㘗կ ׃גծך剑㣐⦼כ53Bitⴓ2 ^ 53 – 1կ ׁחؽحز怴皾遤ֲ㜥さכ32Bit侭侧ח㢌䳔ׁծ
2 ^ 32הזկ
Double Precision Floating Point ⦓礵䏝嵤⹛㼭侧挿侧(DPFP)כ㼰侧12345 ה 10 ^ xחⴓֽג罋ִ 邌植倯岀կ
DPFPכIEEE 754ח״ג⟃♴ך״ֲח㹀纏ׁגְկ 52 11 1 ˟⽃⡘כׅץגؽحز 䊩ַծ痗〾ؽحز٥䭷侧鿇٥⟎侧鿇הְֲせחזגְկ
Double Precision Floating Point A. 痗〾ؽحزהכ1bit⢪ג⦼ָ +ַ-邌植ׅկ B. 䭷侧鿇הכ11ؽحز⢪ג10ך⛦ 皾邌植ׅկ
C. ⟎侧鿇כ53ؽحزך侭侧⦼邌植 ׅկ ׅה⟃♴ך״ֲח㼰侧邌植ֿׅ הָדֹկ (A? +1 : -1) * (C * (10 ^ B))
MAX_SAFE_INTEGER Ecmascriptחכֿך⦓礵䏝嵤⹛㼭侧挿侧ך眔㔲ד㸜Ⰻח鎘皾דֹ ⦼ךMax⦼㹀גֶծ Number.MAX_SAFE_INTEGERה׃ג،ؙإأֿׅהָ〳腉կ ׃גך⦼כ鶢ך(2 ^ 53 – 1)הזկ זזIEEE
754ךDPFPדכ⟎侧鿇ָ52ؽحز׃ַזְַկ
Limitation ׃ַ׃ծMAX_SAFE_INTEGER馄ִ侧⦼ד怴皾׃ְ㜥さכ וֲׅךַ npmٌآُ٦ٕ⢪ֲ • substack/node-bitint • peterolson/BigInteger.js
var bigint = require('bigint');! ! var b = bigint('782910138827292261791972728324982')! .sub('182373273283402171237474774728373')!
.div(8);! ! console.log(b);!
Operator Problem 铣חְֻ… JSכぐ珏怴皾㶨ؔ٦غ٦ٗ٦سדֹזְךדծ 杝荈侧⦼ؙٓأחכַז搀椚ָ֮կ
Ecmascript BigInt ֿדtc39 proposalחEcmascript BigIntָ䲿周ׁկ 植㖈stage3זךדֲ㼰׃ד䱰欽גٓ؎ٝկ
BigInt Overview BigIntכSignedהUnsignedך64bit侭 侧⦼ד邌植ׁկ 侧⦼ٔذٕٓך䖓חn אֽֿה דBigIntٔذٕٓ邌植ׅկ HexװOctalٔذٕٓ؟ه٦زկ侧⦼ ٔذٕٓהずֻׄn劣㽵חאֽֿ הדBigIntחזկ(׃ծOctalכ
0oXXX䕎䒭ך) תծtypeof <bigint>כ 'bigint'ָ䨱կ
function nthPrime(nth) {! function isPrime(p) {! for (let i =
2n; i < p; i++) {! if (p % i === 0n) return false;! }! return true;! }! for (let i = 2n; ; i++) {! if (isPrime(i)) {! if (--nth === 0n) return i;! }! }! }!
BigInt Operators 怴皾㶨כغ؎شٔؔلٖ٦ة٦ + - * ** / % הծ
ぐ珏ؽحز怴皾| & << >> ^ הծ 嫰鯰怴皾㶨 == === < > >= <= ؟ه٦زկ ׃ծ0㙵怴皾㶨 >>> כ؟ه٦ ز׃זְկ
BigInt Objects Number㘗ך״ֲחٓحػ٦ؔـآؙؑزךBigIntؔـآؙؑز欽 䠐ׁկ 䔲搫Constructor欽䠐ׁկ ConstructorכNumberך״ֲח俑㶵װך➭ך㘗BigIntח㢌䳔 ׅկ
new BigInt('34034')! // BigInt {[[PrimitiveValue]]: 34034n}! // new でオブジェクトを生成 !
BigInt('34034')! // 34034n! // 関数呼び出しで変換 ! BigInt.asUintN(width, BigInt)! // 引数BigIntを 0 から 2 ^ widthのサイズのBigIntに変 換する。 ! BigInt.asIntN(width, BigInt)! // 引数BigIntを -2 ^ width から 2 ^ (width - 1) - 1のサイズのBitInt型に変換する。 ! BigInt.parseInt(string[, radix])! // 文字列をradixを基数とするBigInt型に変換する。
BigInt Limitation Number㘗הך幉さכ鏩〳ׁזְկ אתծぐ珏怴皾㶨כBigIntず㡦ד׃ ַ㹋遤דֹזְկ JSךDPFPהך怴皾ך穠卓ָIntegerח זזְךדBigIntך⥂鏾㢩חזג ׃תֲկ את农럀ך㢌䳔כ♧ⴖ遤זְկ ׃ծ嫰鯰怴皾ך幉さֿׅהָ
鏩〳ׁגְկ
TypedArray ׁחTypedArrayח BigInt64ArrayהBigUint64Array㘗ָ鷄⸇ׁ կ Int64הUint64㘗ד侧⦼⥂䭯ׅկ
DataView DataViewח get/set BigInt64 ًاحسָ鷄⸇ׁגծ⦼BitInt㘗ה׃ג《⳿ׇ״ֲחזկ
תה װהjavascriptח64bit侭侧ֹתׅיկ ׀幠耮ָ֮הֲ׀ְׂת׃