|
native 0.0.1
Vectors, masks and wide register packs for C++26
|
JavaScript's conversion to a signed word is defined even when the input is a NaN, infinity or far outside the integer range. JSCVT implements that conversion in one instruction. It is useful whenever the desired result is the low 32 bits of a truncated binary64 value.
Import native.arm.jscvt, or use the native.arm or native hub. native::jcvt<Arch>(double) returns std::int32_t: truncate toward zero, reduce modulo 2³², then interpret the word as signed. NaNs, infinities and signed zeros produce zero.
An out-of-range C++ floating-to-integer cast does not have this contract. Constant evaluation decodes binary64 bits rather than making such a cast. Runtime calls execute FJCVTZS with its floating-point environment behavior; constant evaluation computes the integer result without changing FP status.
Runtime calls require arm_feature::jsconv and a "jsconv" caller target. The module uses the extension's JSCVT spelling; the feature and target use Clang's spelling. Check runtime admission before entering the target function. Importing a module does not check the CPU or enable instructions.
Omitting Arch uses the baseline captured when the module was compiled. An importer's target attribute does not change that default. A tag without JSCVT permits only consteval calls; it supplies no runtime fallback.
See the Arm ACLE conversion contract.