summaryrefslogtreecommitdiff
path: root/doc/api/n-api.md
diff options
context:
space:
mode:
authorKyle Farnung <kfarnung@microsoft.com>2018-03-15 17:22:30 -0700
committerKyle Farnung <kfarnung@microsoft.com>2018-04-08 11:31:12 -0700
commitc5291682491f1b7ee328b7fe5bbd037a91b8a79c (patch)
tree4ff9bd55d75905ccdfbf8f349e90d0ee06270cd6 /doc/api/n-api.md
parent08a36a06667f9b615e09df1bb79eeed5fd5c7000 (diff)
downloadandroid-node-v8-c5291682491f1b7ee328b7fe5bbd037a91b8a79c.tar.gz
android-node-v8-c5291682491f1b7ee328b7fe5bbd037a91b8a79c.tar.bz2
android-node-v8-c5291682491f1b7ee328b7fe5bbd037a91b8a79c.zip
n-api: add more `int64_t` tests
* Updated tests for `Number` and `int32_t` * Added new tests for `int64_t` * Updated N-API `int64_t` behavior to return zero for all non-finite numbers * Clarified the documentation for these calls. PR-URL: https://github.com/nodejs/node/pull/19402 Refs: https://github.com/nodejs/node-chakracore/pull/500 Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'doc/api/n-api.md')
-rw-r--r--doc/api/n-api.md27
1 files changed, 20 insertions, 7 deletions
diff --git a/doc/api/n-api.md b/doc/api/n-api.md
index 673766df16..cece9d1fd1 100644
--- a/doc/api/n-api.md
+++ b/doc/api/n-api.md
@@ -1797,13 +1797,17 @@ napi_status napi_get_value_int32(napi_env env,
- `[out] result`: C int32 primitive equivalent of the given JavaScript Number.
Returns `napi_ok` if the API succeeded. If a non-number `napi_value`
-is passed in `napi_number_expected .
+is passed in `napi_number_expected`.
This API returns the C int32 primitive equivalent
-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.
+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.
+
+Non-finite number values (NaN, positive infinity, or negative infinity) set the
+result to zero.
#### napi_get_value_int64
<!-- YAML
@@ -1822,8 +1826,17 @@ napi_status napi_get_value_int64(napi_env env,
Returns `napi_ok` if the API succeeded. If a non-number `napi_value`
is passed in it returns `napi_number_expected`.
-This API returns the C int64 primitive equivalent of the given
-JavaScript Number.
+This API returns the C int64 primitive equivalent of the given JavaScript
+Number.
+
+Number values outside the range of
+[`Number.MIN_SAFE_INTEGER`](https://tc39.github.io/ecma262/#sec-number.min_safe_integer)
+-(2^53 - 1) -
+[`Number.MAX_SAFE_INTEGER`](https://tc39.github.io/ecma262/#sec-number.max_safe_integer)
+(2^53 - 1) will lose precision.
+
+Non-finite number values (NaN, positive infinity, or negative infinity) set the
+result to zero.
#### napi_get_value_string_latin1
<!-- YAML