Skip to main content
Floating point has NaN and infinity to carry bad results forward. Superfloat has neither. When a result does not fit, the hardware produces a substitute value and, on targets that support it, raises a flag. sf calls these moments events, computes the same substitute value, and reports the event through the error policy.

The four events

The exact result is outside the representable range. The hardware saturates: it returns the largest value with the right sign.
Where it happens: +, -, fma, any cast of a value with |v| >= 1, and a / b whenever |a| >= |b|.Saturation is not undone by later operations: once a sum sticks at the maximum, subtracting what you added does not bring the original back.

The value is always the hardware value

The policy decides whether Python raises, warns or stays quiet. It never changes the number. Under ignore you get exactly what the chip would hand back:
Every error message states the device value so that, when you do choose to raise, you still know what the silicon would have done.

Order when several events happen at once

An array operation can produce different events in different elements, and the policy can only raise once. Events are handled in a fixed order, called the catalogue order: invalid, divide, overflow, underflow. The first one whose policy is raise wins; the rest are warned or ignored per their own setting.

Defaults

Two of the substitute values, divide and invalid, are the chip’s proposed behaviour and are still to be confirmed by the hardware team. They live in one place in the library and will be changed there if the silicon decides otherwise.