This content is not available in your preferred language.

The content is shown in another available language. Your browser may include features that can help translate the text.

Floating Point Case Selector in a LabVIEW Case Structure

Updated Nov 29, 2023

Reported In

Software

  • LabVIEW

Issue Details

I want to use a floating point value to select a case in my LabVIEW case structure.

Solution

Floating point values cannot be directly used in a Case Structure's Case Selector. If you wire a floating point into a case structure, a coercion dot appears, meaning that the number is being turned into an integer and losing precision. However, you can multiply the floating point value by a power of ten, and then convert that value into a signed integer. Then, you can make cases and case ranges that are your desired floating point value multiplied by the same power of ten value.
 

Additional Information

  • Since you are converting a floating point value into an integer, you will lose precision on your floating point value to the number of significant digits your power of ten multiplier has. However, this loss of precision is not as severe as wiring the floating point value in directly.
  • Generally, it is recommended that you use a boolean selector for case selectors with two options, or an enum selector for case selectors with more than two options. These implementations will make your code more readable and easier to debug as it is easier to match cases with their function if they have a descriptive name.