ftsqrt
Float Test for Square Root
ftsqrt BF, FRB
Tests for conditions that would cause a sqrt exception.
Encoding
Binary Layout
63
0:5
BF
6:8
/
9:10
0
11:15
FRB
16:20
160
21:30
/
31
Operands
-
BF
CR Field -
FRB
Source
Reference
View in PowerISA v3.1C Specification ↗
OPF Power ISA v3.1C
Description
Tests the floating-point value in FRB to determine if it would cause an exception when used as the operand to a square root instruction, setting the condition bits in CR field BF accordingly. The result encodes whether the operand is negative, zero, positive, or a special value (NaN, infinity). No floating-point result is produced and FPSCR is not modified.
Operation
if FRB < 0.0 then
CR[BF] ← 0b1000
else if FRB = 0.0 then
CR[BF] ← 0b0100
else if FRB > 0.0 then
CR[BF] ← 0b0010
else
CR[BF] ← 0b0001
Programming Note
The ftsqrt instruction is useful for checking special conditions of a floating-point number before performing square root operations. It sets the FE flag if the operand is zero, NaN, infinity, negative, or has an exponent less than or equal to -970. The FG flag is set if the operand is zero, infinity, or denormalized. Ensure the operand is properly aligned and in double-precision format to avoid unexpected results.