NaN Comparisons in LabVIEW

Let’s start out right with a quick tip for newer LabVIEW developers. The numeric data Staff type in LabVIEW supports a cheap jerseys NaN (Not a Number) value. This can be useful beyond catching zero divided by zero errors. For instance, inserting a NaN into an X-Y Graph’s input arrays at the same wholesale jerseys China indices Motivos displays a “null” point on the graph. This has the effect of creating gaps in your display.

y = x with a русалок random distribution of NaNs.

It can also be a handy when working with VeriStand. Currently, VeriStand User Channels can only be of type double. This limits your options for messaging to models from outside the VeriStand application space. Checking for NaN on an User Channel used as an input to a VeriStand custom device or model is a good shortcut for determining when to start the module. This has the added benefit of eliminating the need for an addition User Channel to indicate that data has arrived and the module should start.

Determining whether a wire contains NaN is a Excited bit counter-intuitive, and if you don’t do it the right way you’ll end up smacking yourself after some wasted time debugging. The seemingly obvious way to check for NaN is compare the wire in question to NaN. This, however, will always return false, even when you compare two NaNs!

Comparing to a NaN will always return false, even when compared to another NaN.

The correct way to check is to use cheap mlb jerseys the Not a Number/Path/Refnum? function in the comparison palette.

Not a Number/Path/Refnum? will return true if the wire contains NaN.

Unfortunately, didnt this isn’t the only place where the behavior of NaN is unlike a number. Attempts to case out NaN in a case structure will result in a broken run arrow. Checking for NaN must be handled separately.

Tags: , ,

1 comment

  1. […] faster earlier today: apparently a NaN from LabVIEW can’t go into a MySQL double. You need to check for NaN before writing to your database. Be especially mindful of this if you’re doing any type of […]

Leave a Reply