Numeric Conversion

LabVIEW 2013 Help

Edition Date: June 2013

Part Number: 371361K-01

»View Product Info

If you wire an output to a destination that has a different numeric representation, LabVIEW converts the data according to the following rules:

  • Signed or unsigned integer to floating-point number—LabVIEW converts the data to the nearest value possible. This conversion is exact when the floating-point number is more precise than the integer. If the integer is more precise than the floating-point number, LabVIEW maintains as much precision as possible in the conversion.
  • Floating-point number to signed or unsigned integer—LabVIEW coerces out-of-range values to the minimum or maximum value of the integer. For example, if you convert a negative floating-point number to an unsigned integer, the result is 0.
  • LabVIEW treats enums as unsigned integers—For example, if you convert –1, a floating-point number, to an enum, LabVIEW coerces the value into the range of the enum. If the range of the enum is 0 to 25, LabVIEW converts the value to 0.
  • Integer to integer—LabVIEW does not coerce out-of-range values to the minimum or maximum value of an integer. If the source is smaller than the destination, LabVIEW extends the sign of a signed source and places zeros in the extra bits of an unsigned source. If the source is larger than the destination, LabVIEW copies only the least significant bits of the value.
  • Integer, floating-point, or fixed-point number to fixed-point number—LabVIEW coerces values outside the desired range for the fixed-point number to within the fixed-point number's maximum and minimum values.

If you wire two different numeric data types to a numeric function that expects the inputs to be the same data type, LabVIEW converts one of the terminals to the same representation as the other terminal. LabVIEW chooses the representation that uses more bits. If the number of bits is the same, LabVIEW chooses unsigned over signed.

Note Note  (FPGA Module) Coercions that occur in FPGA VIs can consume significant logic resources, especially when a terminal is coerced to or from the SGL data type.

LabVIEW places a coercion dot on a block diagram node to alert you that LabVIEW coerced the value passed into the node to a different representation. In certain coercions, coercion dots may lead to an increase in memory usage and execution time and a decrease in accuracy of results. To eliminate coercion dots, match the output data type of the control or constant to the data type of the receiving terminal. You can right-click the control or constant on the block diagram and select Representation from the shortcut menu to change the representation of the input value to the representation of the terminal.


Not Helpful