Skip to content

Commit 8ed4ab5

Browse files
tniessenaddaleax
authored andcommitted
doc: format exponents better
The `2^n` notation is common in mathematics, but even then it often requires parentheses or braces. In JavaScript and C++, the `^` operator stands for bitwise xor, and should be avoided in the docs. In code tags, the JavaScript operator `**` can be used. Otherwise, the `sup` tag can be used for formatting. PR-URL: #35050 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Derek Lewis <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Rich Trott <[email protected]>
1 parent 921129c commit 8ed4ab5

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

doc/api/buffer.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -3113,8 +3113,8 @@ added: v8.2.0
31133113

31143114
* {integer} The largest size allowed for a single `Buffer` instance.
31153115

3116-
On 32-bit architectures, this value currently is `(2^30)-1` (~1GB).
3117-
On 64-bit architectures, this value currently is `(2^31)-1` (~2GB).
3116+
On 32-bit architectures, this value currently is 2<sup>30</sup> - 1 (~1GB).
3117+
On 64-bit architectures, this value currently is 2<sup>31</sup> - 1 (~2GB).
31183118

31193119
This value is also available as [`buffer.kMaxLength`][].
31203120

doc/api/crypto.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2783,7 +2783,7 @@ added: REPLACEME
27832783
Return a random integer `n` such that `min <= n < max`. This
27842784
implementation avoids [modulo bias][].
27852785

2786-
The range (`max - min`) must be less than `2^48`. `min` and `max` must
2786+
The range (`max - min`) must be less than 2<sup>48</sup>. `min` and `max` must
27872787
be safe integers.
27882788

27892789
If the `callback` function is not provided, the random integer is

doc/api/n-api.md

+5-4
Original file line numberDiff line numberDiff line change
@@ -2315,8 +2315,8 @@ This API is used to convert from the C `int64_t` type to the JavaScript
23152315
The JavaScript `Number` type is described in [Section 6.1.6][]
23162316
of the ECMAScript Language Specification. Note the complete range of `int64_t`
23172317
cannot be represented with full precision in JavaScript. Integer values
2318-
outside the range of [`Number.MIN_SAFE_INTEGER`][] `-(2^53 - 1)` -
2319-
[`Number.MAX_SAFE_INTEGER`][] `(2^53 - 1)` will lose precision.
2318+
outside the range of [`Number.MIN_SAFE_INTEGER`][] `-(2**53 - 1)` -
2319+
[`Number.MAX_SAFE_INTEGER`][] `(2**53 - 1)` will lose precision.
23202320

23212321
#### napi_create_double
23222322
<!-- YAML
@@ -2860,7 +2860,7 @@ of the given JavaScript `Number`.
28602860

28612861
If the number exceeds the range of the 32 bit integer, then the result is
28622862
truncated to the equivalent of the bottom 32 bits. This can result in a large
2863-
positive number becoming a negative number if the value is > 2^31 -1.
2863+
positive number becoming a negative number if the value is > 2<sup>31</sup> - 1.
28642864

28652865
Non-finite number values (`NaN`, `+Infinity`, or `-Infinity`) set the
28662866
result to zero.
@@ -2889,7 +2889,8 @@ This API returns the C `int64` primitive equivalent of the given JavaScript
28892889
`Number`.
28902890

28912891
`Number` values outside the range of [`Number.MIN_SAFE_INTEGER`][]
2892-
`-(2^53 - 1)` - [`Number.MAX_SAFE_INTEGER`][] `(2^53 - 1)` will lose precision.
2892+
`-(2**53 - 1)` - [`Number.MAX_SAFE_INTEGER`][] `(2**53 - 1)` will lose
2893+
precision.
28932894

28942895
Non-finite number values (`NaN`, `+Infinity`, or `-Infinity`) set the
28952896
result to zero.

0 commit comments

Comments
 (0)