Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Ecmascript BigInt

Sponsored · Your Podcast. Everywhere. Effortlessly. Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.

Ecmascript BigInt

Ecmascript で導入されそうなBigInt型についてです。

More Decks by Taketoshi Aono(青野健利 a.k.a brn)

Other Decks in Programming

Transcript

  1. せ⵸: @brn (ꫬꅿ⨳ⵃa.k.a ـٕ٦ظ) 耵噟: ؿٗٝزؒٝسؒٝآص،٥iOSؒٝآص، ⠓爡: Cyberagent ،سذؙأةآؔRightSegment٥AI Messenger

    ـؚٗ: http://abcdef.gets.b6n.ch/ Twitter: https://twitter.com/brn227 GitHub: https://github.com/brn
  2. Double Precision Floating Point ⦓礵䏝嵤⹛㼭侧挿侧(DPFP)כ㼰侧׾12345 ה 10 ^ xחⴓֽג罋ִ׷ 邌植倯岀կ

    DPFPכIEEE 754ח״׏ג⟃♴ך״ֲח㹀纏ׁ׸גְ׷կ 52 11 1 ˟⽃⡘כׅץגؽحز 䊩ַ׵ծ痗〾ؽحز٥䭷侧鿇٥⟎侧鿇הְֲせ⵸חז׏גְ׷կ
  3. Double Precision Floating Point A. 痗〾ؽحزהכ1bit׾⢪׏ג⦼ָ +ַ-׾邌植ׅ׷կ B. 䭷侧鿇הכ11ؽحز׾⢪׏ג10ך⛦ 皾׾邌植ׅ׷կ

    C. ⟎侧鿇כ53ؽحزך侭侧⦼׾邌植 ׅ׷կ ׅ׷ה⟃♴ך״ֲח㼰侧׾邌植ׅ׷ֿ הָדֹ׷կ (A? +1 : -1) * (C * (10 ^ B))
  4. 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;! }! }! }!
  5. BigInt Operators 怴皾㶨כغ؎شٔؔلٖ٦ة٦ + - * ** / % הծ

    ぐ珏ؽحز怴皾| & << >> ^ הծ 嫰鯰怴皾㶨 == === < > >= <= ׾؟ه٦زկ ׋׌׃ծ0㙵׭怴皾㶨 >>> כ؟ه٦ ز׃זְկ
  6. 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型に変換する。