LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

"Disconnect Type Definitions.vi" converts double float NaNs to zeros?

Solved!
Go to solution

When I run the following piece of code, which simply passes a double float with a value of NaN through the "Disconnect Type Definitions" VI, the output is zero. I'm using LabVIEW 2016 64-bit.

 

Nan.png

 

I was wondering if this is the intended behavior of this VI or if this is a bug in LabVIEW? The description of the VI only mentions disconnecting the input data from any typedef associations. It does not mention coercing any values.

 

This is causing issues with data that I am exporting to a JSON file. I need to convert my cluster to a variant and pass it through this VI before I export the JSON files, and as a result a number of values that should be showing up as null (which is how the JSON library I'm using interprets NaNs) are showing up as zeros.

0 Kudos
Message 1 of 3
(2,711 Views)
Solution
Accepted by topic author EthanJ

The Data Type VIs do not preserve value. They should only be used for manipulating types. Can you use the type coming out and do a Type Cast to preserve the value, like this?

Untitled.png

0 Kudos
Message 2 of 3
(2,691 Views)

Ah, I had not realized that those VIs were not supposed to preserve value. Thanks!

 

The type cast does not work with the actual cluster I am trying to manipulate, however I seem to have found a workaround for the issue I was encountering for now by flattening to a string then unflattening from a string.

0 Kudos
Message 3 of 3
(2,687 Views)