Skip to content

Commit f03a4d7

Browse files
tniessenrichardlau
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 791a85b commit f03a4d7

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
@@ -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

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

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

28112811
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
@@ -2382,8 +2382,8 @@ This API is used to convert from the C `int64_t` type to the JavaScript
23822382
The JavaScript `Number` type is described in [Section 6.1.6][]
23832383
of the ECMAScript Language Specification. Note the complete range of `int64_t`
23842384
cannot be represented with full precision in JavaScript. Integer values
2385-
outside the range of [`Number.MIN_SAFE_INTEGER`][] `-(2^53 - 1)` -
2386-
[`Number.MAX_SAFE_INTEGER`][] `(2^53 - 1)` will lose precision.
2385+
outside the range of [`Number.MIN_SAFE_INTEGER`][] `-(2**53 - 1)` -
2386+
[`Number.MAX_SAFE_INTEGER`][] `(2**53 - 1)` will lose precision.
23872387

23882388
#### napi_create_double
23892389
<!-- YAML
@@ -2929,7 +2929,7 @@ of the given JavaScript `Number`.
29292929

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

29342934
Non-finite number values (`NaN`, `+Infinity`, or `-Infinity`) set the
29352935
result to zero.
@@ -2958,7 +2958,8 @@ This API returns the C `int64` primitive equivalent of the given JavaScript
29582958
`Number`.
29592959

29602960
`Number` values outside the range of [`Number.MIN_SAFE_INTEGER`][]
2961-
`-(2^53 - 1)` - [`Number.MAX_SAFE_INTEGER`][] `(2^53 - 1)` will lose precision.
2961+
`-(2**53 - 1)` - [`Number.MAX_SAFE_INTEGER`][] `(2**53 - 1)` will lose
2962+
precision.
29622963

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

0 commit comments

Comments
 (0)