Table Of Contents

Overflow in the Fixed-Point Data Type

Last Modified: September 20, 2016

Overflow in the fixed-point data type occurs when an input or computed result of an operation is greater than the maximum representable value or less than the minimum representable value of a given fixed-point configuration.

Any time overflow occurs in your code, the overflow mode you select determines how LabVIEW coerces the value. You specify the overflow mode in the Terminals section of the Item tab for an operator.

The following table describes how LabVIEW coerces overflow values in each overflow mode.

Overflow Mode Behavior
Saturate If the value is greater than the maximum value in the specified range of the output type, LabVIEW coerces the value to the specified maximum. If the value is less than the minimum value in the specified range of the output type, LabVIEW coerces the value to the specified minimum. Saturate is the default overflow mode in LabVIEW.
Wrap If the value is greater than the maximum value or less than the minimum value of the specified range of the output type, LabVIEW discards the most significant bits of the value until the value is within the range of the output type.

Consider an example scenario where an input value exceeds the maximum representable value for an arbitrary configuration. Keep in mind that the Saturate and Wrap overflow modes affect the binary representation of fixed-point numbers. The binary representation of the decimal number 6.75 is 110.11. So the decimal number 6.75 requires at least a <3.2> unsigned fixed-point configuration to be represented exactly. If the decimal number 6.75 converts to a <2.2> unsigned fixed-point number, it exceeds the maximum value for the specified configuration. The following table demonstrates how the LabVIEW behaviors for Saturate and Wrap differ when coercing the example decimal number 6.75.

Example FXP Configuration Overflow Mode Input Value (Decimal) Input Value (Binary) Coerced Value (Binary) Coerced Value (Decimal)
U4 <2.2> Saturate 6.75 110.11 11.11 3.75
U4 <2.2> Wrap 6.75 110.11 10.11 2.75

Using the Saturate overflow mode, LabVIEW coerces the decimal number 6.75 to 3.75, the maximum value of an unsigned <2.2> fixed-point number. Using the Wrap overflow mode, LabVIEW coerces the decimal number 6.75 to 2.75 by discarding an integer bit from the binary input value.


Recently Viewed Topics