Skip to main content

Comparisons

All six comparisons compare exact values. They never quantize a host number and never raise.
Comparing values of different widths compares their exact values, so sf.sf8(0.5) == sf.sf16(0.5) is True.

Truth value

bool(x) is False for zero and True otherwise. int(x) is 0 for every value, because the whole range lies inside (-1, 1); use x.code for the integer.

Selection

These pick one of their inputs. They work on codes, are exact, and cannot produce an event.
clip’s bounds and where’s branches follow the literal rule: a host number is quantized to the operand’s type first. At least one branch of where must be a Superfloat value so the result type is known.

Guarded division

The usual pattern for a division that might hit zero: compare first, select after.
On arrays this is what sf.div(a, b, where=b != 0) does for you. Arrays: elementwise →