Assignment and overflow handling

When assigning one Fix object to another with different precission, an overflow might occur. These overflows are handled by the assignment operator.

Once a Fix object has been initialized, its precision does not change as long as the object exists. The assignment operator is overloaded so it checks whether the value of the object to the right of the assignment fits into the precision of the left object. If not, it then takes the appropriate overflow response and sets the overflow error bit.

If a Fix object is with no arguments in the constructor, as in the protected declaration in the AddFix primitive, then that object is an uninitialized Fix . It can accept any assignment, acquiring not only its value, but also its precision and overflow handler.

The behavior of a Fix object on an overflow depends on the specifications and the behavior of the object itself. Each object has a private data field that is initialized by the constructor. If there is an overflow, the overflow_handler looks at this field and uses the specified method to handle the overflow. This data field is set to saturate by default, and can be set explicitly to any other desired overflow handling method using a function called set_ovflow(<keyword>). The keywords for overflow handling methods are:

saturate replaces the original value with the maximum (for overflow) or minimum (for underflow) value representable, given the precision of the Fix object. zero_saturate sets the value to zero.