napi_create_int64


napi_status napi_create_int64(napi_env env, int64_t value, napi_value* result) 
  • [in] env:调用该 API 时所处的环境。
  • [in] value:要在 JavaScript 中表示的整数值。
  • [out] result:一个表示 JavaScript numbernapi_value

如果 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 语言规范的 节号类型 中进行了描述。请注意,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 number type 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.】