napi_create_int64
napi_status napi_create_int64(napi_env env, int64_t value, napi_value* result) -
[in] env:调用 API 的环境。¥
[in] env: The environment that the API is invoked under. -
[in] value:要在 JavaScript 中表示的整数值。¥
[in] value: Integer value to be represented in JavaScript. -
[out] result:代表 JavaScriptnumber的napi_value。¥
[out] result: Anapi_valuerepresenting a JavaScriptnumber.
如果 API 成功,则返回 napi_ok。
¥Returns napi_ok if the API succeeded.
该 API 用于将 C int64_t 类型转换为 JavaScript number 类型。
¥This API is used to convert from the C int64_t type to the JavaScript
number type.
JavaScript number 类型在 ECMAScript 语言规范的 第 6.1.6 节 中进行了描述。请注意,无法在 JavaScript 中完全精确地表示 int64_t 的完整范围。超出 Number.MIN_SAFE_INTEGER -(2**53 - 1) 范围的整数值 - Number.MAX_SAFE_INTEGER (2**53 - 1) 将失去精度。
¥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.