The Fix class defines the following enumeration values for overflow handling:
Fix::ovf_saturate
Fix::ovf_zero_saturate
Fix::ovf_wrapped
Fix::ovf_warning
They may be used as arguments to the set_overflow method, as in the following example:
out.set_overflow(Fix::ovf_saturate);
The member function
int overflow() const;
returns the overflow type. This returned result can be compared against the above enumerated values. Overflow types may also be specified as strings, using the method
void set_ovflow(const char* overflow_type);
the overflow_type argument may be one of saturate, zero_saturate, wrapped or warning.
The rounding behavior of a Fix value may be set by calling
void set_rounding(int value);
If the argument is false, or has the value Fix::mask_truncate, then truncation will occur. If the argument is nonzero, for example, if it has the value Fix::mask_truncate_round, rounding will occur. The older name Set_MASK is a synonym for set_rounding. The following functions access the error bits of a Fix result:
int ovf_occurred() const;
int invalid() const;
int dbz() const;
The first function returns TRUE if there have been any overflows in computing the value. The second returns TRUE if the value is invalid, because of invalid precision parameters or a divide by zero. The third returns TRUE only for divide by zero.