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
Taketoshi Aono(青野健利 a.k.a brn)
August 24, 2017
Programming
600
3
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Ecmascript BigInt
Ecmascript で導入されそうなBigInt型についてです。
Taketoshi Aono(青野健利 a.k.a brn)
August 24, 2017
More Decks by Taketoshi Aono(青野健利 a.k.a brn)
See All by Taketoshi Aono(青野健利 a.k.a brn)
document.write再考
brn
6
3.2k
Parsing Javascript
brn
14
9.6k
JSON & Object Tips
brn
1
590
CA 1Day Youth Bootcamp for Frontend LT
brn
0
1.1k
Modern TypeScript
brn
2
890
javascript - behind the scene
brn
3
820
tc39 proposals
brn
0
1k
プロダクト開発とTypeScript
brn
7
3k
React-Springでリッチなアニメーション
brn
1
780
Other Decks in Programming
See All in Programming
PostgreSQL 18で考えるUUID主キー
kazuhiro1982
0
500
複数の Claude Code が"放置"されてしまう問題をCLI ダッシュボードを自作して解決した話
sumihiro3
1
730
承認済みなのに差戻しできてしまうバグ、型で潰せます
shinchit
0
110
Loosening the Reins: Go Generics Get More Flexible
kuro_kurorrr
0
330
メールのエイリアス機能を履き違えない
isshinfunada
0
260
Gmail/Google DriveをトリガーにAIエージェントを動かそう! / Run AI agents with Gmail/Google Drive as triggers!
har1101
2
440
引き算の組織 ― アウトカムとAIに全振りするために辞めたこと ― / Organization by Subtraction
hirokiyamamoto14
PRO
0
300
自動化したのに回らない テスト運用の壁―AI時代の品質責任と生産性
mfunaki
0
510
Android CLI
fornewid
0
240
源内ハンズオン概要編
hideg
0
210
ALB ログから Trace を気合で繋げる技術
fohte
6
690
Detecting Compromised CI with eBPF and Cilium Tetragon
lizrice
0
260
Featured
See All Featured
Digital Projects Gone Horribly Wrong (And the UX Pros Who Still Save the Day) - Dean Schuster
uxyall
1
2.5k
HDC tutorial
michielstock
2
820
How to audit for AI Accessibility on your Front & Back End
davetheseo
0
510
YesSQL, Process and Tooling at Scale
rocio
174
15k
Claude Code どこまでも/ Claude Code Everywhere
nwiizo
67
57k
Being A Developer After 40
akosma
91
590k
Breaking role norms: Why Content Design is so much more than writing copy - Taylor Woolridge
uxyall
1
380
DBのスキルで生き残る技術 - AI時代におけるテーブル設計の勘所
soudai
PRO
68
57k
Reality Check: Gamification 10 Years Later
codingconduct
0
2.3k
Hiding What from Whom? A Critical Review of the History of Programming languages for Music
tomoyanonymous
3
1.1k
Building Better People: How to give real-time feedback that sticks.
wjessup
370
20k
Ecommerce SEO: The Keys for Success Now & Beyond - #SERPConf2024
aleyda
1
2.1k
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侭侧ֹתׅיկ ׀幠耮ָ֮הֲ׀ְׂת׃