When you wire numeric data to a node that expects a different numeric data type, the node coerces the data to the most precise type. A red coercion dot appears where the coercion takes place. Because numeric coercions can affect memory usage, performance of a VI, or cause a VI to generate inaccurate results, use one of the strategies in the following table to eliminate or reduce the impact of a problematic coercion.
|Match input data types.||Create an object that matches the data type the node expects. If you wire data from a G type to a node or subVI that does not accept the data type of the G type, your VI may break or generate inaccurate data. Replace the node or subVI with one that matches the data type used in the G type, or replace the G type with a constant of the matching data type.||Right-click the coerced control, constant, or indicator on the diagram, select Representation from the shortcut menu, and select the matching data type.||
In the following diagram, the red coercion dot on the top input of the Add node indicates that the node is coercing I16 (x), a signed integer, to an unsigned integer to match the data type of U16 (y). This causes Add to return a sum of 65,531 instead of -5.
If you change the data type representation of I16 (x) so that both inputs are signed integers, no coercion is necessary, and the node performs an accurate computation, as you can see in the following diagram.
|Use a conversion node.||Conversion nodes convert one data type to another. Conversion nodes have the same effect as the automatic coercions that occur when you wire numeric data to a node that expects a different numeric data type. However, when you use a conversion node you can control where in your VI the conversion takes place, which can improve VI performance in certain cases.||To add a conversion node from the diagram palette, navigate to and select the desired conversion node.||You may want to use a conversion node inside a loop that generates an array so the conversion is performed before the VI generates the array. This allows you to avoid a large data buffer. In the following diagram, To Single Precision Float converts the Random Number output to a single-precision number inside the For Loop to prevent the Add node from converting a large amount of data.|