Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(data-type): BigIntのセクションを追加 #1184

Merged
merged 10 commits into from
Aug 22, 2020
Merged

Conversation

azu
Copy link
Collaborator

@azu azu commented Jun 20, 2020

data-typeにBigIntのリテラルについてを追加

  • BigIntとは巨大な整数を表現するための新しいリテラル
  • 1n のように n というsuffixをつけるリテラル
  • 数値リテラルでは2^53-1よりも大きな値は精度が足りずに正確に表現できない
  • BigInt自体は7番目の新しいプリミティブ型として定義されている
  • そのため、typeofに"bigint"が追加されている
  • 浮動小数点表現にnをつけた場合は構文エラーとなる

やらなかったこと

  • 数値型との演算はできない(変換が必要) → そもそもこの章は演算してない

fix #445

@bot-user

This comment has been minimized.

@bot-user
Copy link

bot-user commented Jun 20, 2020

Deploy preview for js-primer ready!

Built with commit e0962cd

https://deploy-preview-1184--js-primer.netlify.app

@@ -22,11 +22,12 @@ JavaScriptでは、文字列も一度作成したら変更できないイミュ
オブジェクトは、一度作成した後もその値自体を変更できるためミュータブル(mutable)の特性を持ちます。
オブジェクトは、値そのものではなく値への参照を経由して操作されるため、参照型のデータとも言います。

データ型を細かく見ていくと、6つのプリミティブ型とオブジェクトからなります
データ型を細かく見ていくと、7つのプリミティブ型とオブジェクトからなります
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ここが増えたので、詳細は省くにしろBigIntは入れないと駄目な感じ

@asciidwango asciidwango deleted a comment from bot-user Jun 20, 2020

これらのリテラルで表現できる数値は[IEEE 754][]の64bitフォーマット(倍精度)で扱われます。
64bitのうち52bitが数字の格納のために使われ、11bitを小数点の位置に使い、残りの1bitはプラスとマイナスの符号です。
そのため、正確に扱える数値の最大値は`2^53-1`(2の53乗から1引いた値)となります。
Copy link
Collaborator Author

@azu azu Jun 20, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

数値の絶対値の範囲? とするのもありかな

@@ -189,7 +195,6 @@ console.log(0x30A2); // => 12450

#### 浮動小数点数リテラル {#floating-point-number-literal}

JavaScriptの浮動小数点数は[IEEE 754][]を採用しています。
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

これ数値型で共通なのでいどうした


- プリミティブ型(基本型)
- 真偽値(Boolean): `true`または`false`のデータ型
- 数値(Number): `42` や `3.14159` などの数値のデータ型
- 巨大な整数(BigInt): ES2020から追加された`9007199254740992n`などの任意精度の整数のデータ型
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

知ってる人はBigIntで通じると思うので、こんな感じでいいかな。

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

@lacolaco lacolaco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

コメントしました


- プリミティブ型(基本型)
- 真偽値(Boolean): `true`または`false`のデータ型
- 数値(Number): `42` や `3.14159` などの数値のデータ型
- 巨大な整数(BigInt): ES2020から追加された`9007199254740992n`などの任意精度の整数のデータ型
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

```

<!-- textlint-enable -->

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

10進数以外のリテラルにnをつけてもbigintとしては10進数表現に固定される話はnice to haveかな

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

> 0x12n
18n

たしかに。でも使い道が思いつかないのでなくてもよさそう。

azu and others added 2 commits August 22, 2020 16:39
Co-authored-by: Suguru Inatomi <suguru.inatomi@gmail.com>
Co-authored-by: Suguru Inatomi <suguru.inatomi@gmail.com>
@azu
Copy link
Collaborator Author

azu commented Aug 22, 2020

レビューありがとうございます

@azu azu merged commit 5b31466 into master Aug 22, 2020
@azu azu deleted the feature/445-bigint branch August 22, 2020 07:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

データ型とリテラル: BigInt(ES2020+)
4 participants