Skip to content

Commit

Permalink
doc: format exponents better
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
tniessen authored and richardlau committed Sep 7, 2020
1 parent 791a85b commit f03a4d7
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
4 changes: 2 additions & 2 deletions doc/api/buffer.md
Original file line number Diff line number Diff line change
Expand Up @@ -3137,8 +3137,8 @@ added: v8.2.0

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

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

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

Expand Down
2 changes: 1 addition & 1 deletion doc/api/crypto.md
Original file line number Diff line number Diff line change
Expand Up @@ -2805,7 +2805,7 @@ added: REPLACEME
Return a random integer `n` such that `min <= n < max`. This
implementation avoids [modulo bias][].

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

If the `callback` function is not provided, the random integer is
Expand Down
9 changes: 5 additions & 4 deletions doc/api/n-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -2382,8 +2382,8 @@ This API is used to convert from the C `int64_t` type to the JavaScript
The JavaScript `Number` type is described in [Section 6.1.6][]
of the ECMAScript Language Specification. Note the complete range of `int64_t`
cannot be represented with full precision in JavaScript. Integer values
outside the range of [`Number.MIN_SAFE_INTEGER`][] `-(2^53 - 1)` -
[`Number.MAX_SAFE_INTEGER`][] `(2^53 - 1)` will lose precision.
outside the range of [`Number.MIN_SAFE_INTEGER`][] `-(2**53 - 1)` -
[`Number.MAX_SAFE_INTEGER`][] `(2**53 - 1)` will lose precision.

#### napi_create_double
<!-- YAML
Expand Down Expand Up @@ -2929,7 +2929,7 @@ of the given JavaScript `Number`.

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

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

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

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

0 comments on commit f03a4d7

Please sign in to comment.