-
-
Notifications
You must be signed in to change notification settings - Fork 225
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
Conversation
This comment has been minimized.
This comment has been minimized.
Deploy preview for js-primer ready! Built with commit e0962cd |
@@ -22,11 +22,12 @@ JavaScriptでは、文字列も一度作成したら変更できないイミュ | |||
オブジェクトは、一度作成した後もその値自体を変更できるためミュータブル(mutable)の特性を持ちます。 | |||
オブジェクトは、値そのものではなく値への参照を経由して操作されるため、参照型のデータとも言います。 | |||
|
|||
データ型を細かく見ていくと、6つのプリミティブ型とオブジェクトからなります。 | |||
データ型を細かく見ていくと、7つのプリミティブ型とオブジェクトからなります。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ここが増えたので、詳細は省くにしろBigIntは入れないと駄目な感じ
|
||
これらのリテラルで表現できる数値は[IEEE 754][]の64bitフォーマット(倍精度)で扱われます。 | ||
64bitのうち52bitが数字の格納のために使われ、11bitを小数点の位置に使い、残りの1bitはプラスとマイナスの符号です。 | ||
そのため、正確に扱える数値の最大値は`2^53-1`(2の53乗から1引いた値)となります。 |
There was a problem hiding this comment.
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][]を採用しています。 |
There was a problem hiding this 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`などの任意精度の整数のデータ型 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
知ってる人はBigIntで通じると思うので、こんな感じでいいかな。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this 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`などの任意精度の整数のデータ型 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
``` | ||
|
||
<!-- textlint-enable --> | ||
|
There was a problem hiding this comment.
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かな
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
> 0x12n
18n
たしかに。でも使い道が思いつかないのでなくてもよさそう。
Co-authored-by: Suguru Inatomi <suguru.inatomi@gmail.com>
Co-authored-by: Suguru Inatomi <suguru.inatomi@gmail.com>
レビューありがとうございます |
data-typeにBigIntのリテラルについてを追加
1n
のようにn
というsuffixをつけるリテラル2^53-1
よりも大きな値は精度が足りずに正確に表現できないn
をつけた場合は構文エラーとなるやらなかったこと
fix #445