napi_get_value_int32
napi_status napi_get_value_int32(napi_env env,
napi_value value,
int32_t* result) -
[in] env:调用 API 的环境。¥
[in] env: The environment that the API is invoked under. -
[in] value:napi_value代表 JavaScriptnumber。¥
[in] value:napi_valuerepresenting JavaScriptnumber. -
[out] result:给定的 JavaScriptnumber的 Cint32基础类型等价物。¥
[out] result: Cint32primitive equivalent of the given JavaScriptnumber.
如果 API 成功,则返回 napi_ok。如果在 napi_number_expected 中传递了非数字 napi_value。
¥Returns napi_ok if the API succeeded. If a non-number napi_value
is passed in napi_number_expected.
此 API 返回给定 JavaScript number 的 C int32 基础类型等价物。
¥This API returns the C int32 primitive equivalent
of the given JavaScript number.
如果该数字超出 32 位整数的范围,则结果将被截断为与底部 32 位等效的值。如果该值 > 231,这可能会导致较大的正数变成负数 - 1.
¥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 > 231 - 1.
非有限数值(NaN、+Infinity 或 -Infinity)将结果设置为零。
¥Non-finite number values (NaN, +Infinity, or -Infinity) set the
result to zero.