Skip to content
Tutorials Center
My learning

Topics

Lesson 14 of 36 Β· Data Types and Arrays

Numeric and Boolean Data

Learn LabVIEW numeric representations (I8 to U64, SGL, DBL, EXT, complex), coercion dots, overflow, rounding, Boolean logic and mechanical actions.

LabVIEW is strongly typed: every wire has a type, and the wire color shows it. Picking the right numeric representation prevents overflow, wasted memory and hidden rounding. This lesson covers numbers and Booleans in the real product. LabVIEW cannot run here, so the runnable examples are JavaScript stand-ins that reproduce the arithmetic rules; they are not LabVIEW output.

Numeric representations

Right-click a numeric control or indicator and open Representation to choose a type.

Type Meaning Range or precision
I8, I16, I32, I64 Signed integers I32: -2,147,483,648 to 2,147,483,647
U8, U16, U32, U64 Unsigned integers U8: 0 to 255; U16: 0 to 65,535
SGL 32-bit float about 7 digits
DBL 64-bit float about 15 to 16 digits (the default)
EXT Extended float platform-dependent, more precision
CSG, CDB, CXT Complex numbers Pairs of floats
Fixed-point (FXP) Fixed-point Configurable word and integer lengths, for FPGA

Integers are blue and floating point orange on the diagram, with complex numbers a darker orange. Use DBL for general measurements, and an integer type for counts, indexes and bit patterns. A U8 array is the right shape for raw bytes.

Overflow wraps around

Integer arithmetic does not raise an error when it overflows. It wraps: a U8 holding 255 plus 1 becomes 0, an I8 at 127 plus 1 becomes -128. The Increment function on an unsigned counter will quietly roll over. Check ranges before they matter, or use a wider type. Floating-point values overflow to Inf and invalid results become NaN (not a number). Always handle NaN, because it is not equal to itself; use the Not A Number/Path/Refnum? function to test.

Coercion dots

When a wire of one numeric type meets a terminal of another, LabVIEW converts automatically and shows a coercion dot (a small red dot) on the terminal. Typical cases:

  • Integer into a floating-point input: fine, but a big I64 may lose precision in a DBL.
  • DBL into an integer input: LabVIEW rounds to nearest (ties to even) and clips values that do not fit.

Coercion saves wiring but can hide losses. Convert explicitly with the functions in Numeric > Conversion (To Double Precision Float, To Long Integer, To Word Integer, To Unsigned Byte Integer, and so on) when the conversion matters. These conversion functions follow the same round-to-nearest rule, and conversions of out-of-range values saturate to the limits of the target type.

Choosing a numeric type

DBL Measurements
I32 Counts, indexes
U8 Bytes
SGL Saves memory

Dots mean implicit conversion.

1 / 2

Numeric functions

Programming > Numeric holds the arithmetic you expect: Add, Subtract, Multiply, Divide, Quotient & Remainder, Absolute Value, Round To Nearest, Round to +Infinity, Round to -Infinity, Square Root, Power of X, Random Number (0-1), and more. Most are polymorphic: they accept scalars, arrays and clusters, working element by element. Adding a scalar to an array adds it to every element; adding two arrays of different lengths gives the shorter length.

Compound Arithmetic adds or multiplies many inputs with one node. Scale By Power Of 2 and Logical Shift work on integers. Trig and exponent functions are under Mathematics > Elementary.

Boolean data

A Boolean is a single True or False value, drawn green. Boolean functions (Programming > Boolean) include And, Or, Not, Exclusive Or, Not And, Not Or, and the Compound Arithmetic node set to AND or OR for many inputs. The same functions act bitwise on integers: AND of two U8 values compares bits.

Comparison functions (Programming > Comparison) such as Equal?, Greater?, In Range and Coerce return Booleans. Beware comparing floating-point values for exact equality, since 0.1 + 0.2 does not equal 0.3 exactly in binary. Use Equal Within Tolerance or compare the absolute difference to a small limit.

Boolean mechanical action

A Boolean control has a mechanical action (right-click > Mechanical Action) that decides how it behaves when you click it:

  • Switch When Pressed and Switch When Released: toggles like a light switch.
  • Switch Until Released: True while the mouse is down.
  • Latch When Pressed and Latch When Released: becomes True, and returns to False after the VI reads it once. Perfect for a Stop button or an Acquire button.
  • Latch Until Released.

Rule: use Latch When Released for most buttons that trigger an action once. Do not read a latched Boolean in two places, because the first read resets it and the second will see False.

Enums and rings

Not numbers exactly, but close: an Enum is an unsigned integer paired with text labels, and a Ring is a numeric with text labels that need not be consecutive. Prefer enums for named choices and states.

Stand-in 1: integer overflow and rounding

This models how fixed-width integers wrap and how conversions round and clip, using typed arrays, which behave like fixed-width numeric types. It is an analogy to LabVIEW's behavior.

JS Stand-in: wrap-around, rounding, clipping

Press Run (or Ctrl + Enter) to see the console output here.

No output.

Stand-in 2: mechanical action of Booleans

The stand-in models Switch When Pressed versus Latch When Released so you can see why a latched Boolean resets after one read.

JS Stand-in: Boolean mechanical actions

Press Run (or Ctrl + Enter) to see the console output here.

No output.

Check your understanding

Quick check Β· 4 questions

of 4 answered You scored / 4 Β· perfect!

  1. 1. What does U8 255 + 1 give?

    Integer arithmetic wraps around silently.
  2. 2. What does a coercion dot indicate?

    The dot marks where LabVIEW converted one numeric type to another.
  3. 3. Which Boolean mechanical action suits a Stop button?

    A latch returns to False after being read once, so it does not need resetting.
  4. 4. Why is comparing DBL values with Equal? risky?

    Use Equal Within Tolerance or compare an absolute difference to a small limit.

Summary

  • Choose a numeric type deliberately: DBL for measurements, integers for counts and bits.
  • Integers wrap on overflow; floats go to Inf or NaN; conversions round to nearest and clip.
  • Coercion dots show implicit conversions: check them.
  • Boolean mechanical action decides how buttons behave; use latches for one-shot triggers.
  • Prefer enums for named choices.

Next: Strings and Paths