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
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
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
Basic Architectures
denyspoltorak
0
670
なぜSQLはAIぽく見えるのか/why does SQL look AI like
florets1
0
450
Unicodeどうしてる? PHPから見たUnicode対応と他言語での対応についてのお伺い
youkidearitai
PRO
1
2.5k
AIによる開発の民主化を支える コンテキスト管理のこれまでとこれから
mulyu
3
190
AIと一緒にレガシーに向き合ってみた
nyafunta9858
0
190
AI Schema Enrichment for your Oracle AI Database
thatjeffsmith
0
260
CSC307 Lecture 04
javiergs
PRO
0
660
CSC307 Lecture 07
javiergs
PRO
0
550
そのAIレビュー、レビューしてますか? / Are you reviewing those AI reviews?
rkaga
6
4.5k
【卒業研究】会話ログ分析によるユーザーごとの関心に応じた話題提案手法
momok47
0
190
AtCoder Conference 2025
shindannin
0
1.1k
余白を設計しフロントエンド開発を 加速させる
tsukuha
7
2.1k
Featured
See All Featured
Beyond borders and beyond the search box: How to win the global "messy middle" with AI-driven SEO
davidcarrasco
1
49
Testing 201, or: Great Expectations
jmmastey
46
8k
GitHub's CSS Performance
jonrohan
1032
470k
Mind Mapping
helmedeiros
PRO
0
79
Navigating the Design Leadership Dip - Product Design Week Design Leaders+ Conference 2024
apolaine
0
170
世界の人気アプリ100個を分析して見えたペイウォール設計の心得
akihiro_kokubo
PRO
66
36k
Designing for humans not robots
tammielis
254
26k
The Mindset for Success: Future Career Progression
greggifford
PRO
0
230
Avoiding the “Bad Training, Faster” Trap in the Age of AI
tmiket
0
75
Leadership Guide Workshop - DevTernity 2021
reverentgeek
1
200
Music & Morning Musume
bryan
47
7.1k
Into the Great Unknown - MozCon
thekraken
40
2.3k
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侭侧ֹתׅיկ ׀幠耮ָ֮הֲ׀ְׂת׃