Upgrade to PRO for Only $50/Year—Limited-Time Offer! 🔥
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Ecmascript BigInt
Search
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
530
CA 1Day Youth Bootcamp for Frontend LT
brn
0
1k
Modern TypeScript
brn
2
840
javascript - behind the scene
brn
3
780
tc39 proposals
brn
0
930
プロダクト開発とTypeScript
brn
8
3k
React-Springでリッチなアニメーション
brn
1
730
Other Decks in Programming
See All in Programming
JETLS.jl ─ A New Language Server for Julia
abap34
1
400
Full-Cycle Reactivity in Angular: SignalStore mit Signal Forms und Resources
manfredsteyer
PRO
0
140
AtCoder Conference 2025「LLM時代のAHC」
imjk
2
480
マスタデータ問題、マイクロサービスでどう解くか
kts
0
100
生成AIを利用するだけでなく、投資できる組織へ
pospome
2
330
ViewファーストなRailsアプリ開発のたのしさ
sugiwe
0
470
ハイパーメディア駆動アプリケーションとIslandアーキテクチャ: htmxによるWebアプリケーション開発と動的UIの局所的適用
nowaki28
0
420
Navigation 3: 적응형 UI를 위한 앱 탐색
fornewid
1
330
Findy AI+の開発、運用におけるMCP活用事例
starfish719
0
560
Cap'n Webについて
yusukebe
0
130
チームをチームにするEM
hitode909
0
330
FluorTracer / RayTracingCamp11
kugimasa
0
230
Featured
See All Featured
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.3k
Why You Should Never Use an ORM
jnunemaker
PRO
61
9.6k
Code Reviewing Like a Champion
maltzj
527
40k
Rebuilding a faster, lazier Slack
samanthasiow
84
9.3k
Testing 201, or: Great Expectations
jmmastey
46
7.8k
RailsConf 2023
tenderlove
30
1.3k
How to train your dragon (web standard)
notwaldorf
97
6.4k
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.6k
Java REST API Framework Comparison - PWX 2021
mraible
34
9k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
359
30k
Scaling GitHub
holman
464
140k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.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侭侧ֹתׅיկ ׀幠耮ָ֮הֲ׀ְׂת׃