Skip to content

Commit 699fae1

Browse files
tniessenTrott
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 6d9a316 commit 699fae1

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

doc/api/buffer.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3137,8 +3137,8 @@ added: v8.2.0
31373137

31383138
* {integer} The largest size allowed for a single `Buffer` instance.
31393139

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

31433143
This value is also available as [`buffer.kMaxLength`][].
31443144

doc/api/crypto.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2813,7 +2813,7 @@ added: REPLACEME
28132813
Return a random integer `n` such that `min <= n < max`. This
28142814
implementation avoids [modulo bias][].
28152815

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

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

doc/api/n-api.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2385,8 +2385,8 @@ This API is used to convert from the C `int64_t` type to the JavaScript
23852385
The JavaScript `Number` type is described in [Section 6.1.6][]
23862386
of the ECMAScript Language Specification. Note the complete range of `int64_t`
23872387
cannot be represented with full precision in JavaScript. Integer values
2388-
outside the range of [`Number.MIN_SAFE_INTEGER`][] `-(2^53 - 1)` -
2389-
[`Number.MAX_SAFE_INTEGER`][] `(2^53 - 1)` will lose precision.
2388+
outside the range of [`Number.MIN_SAFE_INTEGER`][] `-(2**53 - 1)` -
2389+
[`Number.MAX_SAFE_INTEGER`][] `(2**53 - 1)` will lose precision.
23902390

23912391
#### napi_create_double
23922392
<!-- YAML
@@ -2932,7 +2932,7 @@ of the given JavaScript `Number`.
29322932

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

29372937
Non-finite number values (`NaN`, `+Infinity`, or `-Infinity`) set the
29382938
result to zero.
@@ -2961,7 +2961,8 @@ This API returns the C `int64` primitive equivalent of the given JavaScript
29612961
`Number`.
29622962

29632963
`Number` values outside the range of [`Number.MIN_SAFE_INTEGER`][]
2964-
`-(2^53 - 1)` - [`Number.MAX_SAFE_INTEGER`][] `(2^53 - 1)` will lose precision.
2964+
`-(2**53 - 1)` - [`Number.MAX_SAFE_INTEGER`][] `(2**53 - 1)` will lose
2965+
precision.
29652966

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

0 commit comments

Comments
 (0)