fctiwz
Floating Convert to Integer Word with Round to Zero
Converts Double to 32-bit Int (Truncate).
Details
Floating Convert to Integer Word with Round to Zero converts the double-precision floating-point value in FRB to a signed 32-bit integer, truncating toward zero, and places the result in FRT as a floating-point representation. FPSCR is updated with FPRF, FR, and FI flags; exception flags (XX, ZX) are set if applicable.
Pseudocode Operation
FRT ← (int32_t)truncate(FRB)
Update FPSCR[FPRF, FR, FI, XX, ZX]
Programming Note
The fctiwz instruction is commonly used for converting floating-point numbers to integers with truncation. Be cautious of NaN inputs, which will result in zero and set VXCVI; SNaNs also set VXSNAN. Ensure the input is within the 32-bit signed integer range to avoid saturation. This instruction operates at user privilege level.
Example
Encoding
Operands
-
FRT
Target -
FRB
Source