ftsqrt
Float Test for Square Root
Tests for conditions that would cause a sqrt exception.
Details
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.
Pseudocode 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.
Example
Encoding
Operands
-
BF
CR Field -
FRB
Source