NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Return double value NAN from CVI code module

When I return the value NAN from a CVI function in a DLL used as a code module, TestStand displays it as IND. I'm thinking the conversion is a feature of the CVI adapter.

 

I want it to show as NAN in my report. Will I have to do some manipulation to get that result?

 

Simple CVI function

#include <math.h>

void ReturnNAN(double *val) { *val = NAN; }

IND.png

 

 

According to CVI's help for C99 extensions,  NAN is a quiet NAN.

According to TestStand's help for special constant values, NAN is a quiet NAN, and IND is a Signaling NAN.

 

I'm using TestStand 2010 SP1 and CVI 2010. Could someone check this with TestStand 2013 and CVI 2013 for me?

 

Edit: I just tested with the C/C++ adapter, and I get the same behavior.

Edit 2: I just tested changing the sign of the return value (i.e. *val = -NAN). The value is still displayed as IND

Josh W.
Certified TestStand Architect
Formerly blue
0 Kudos
Message 1 of 4
(4,545 Views)

I do not think any conversion is being done at all on the teststand side. Have you tried writing similar code in visual C++ and seeing what you get? That would help determine if it's a CVI issue or a TestStand issue.

 

You do realize that nan and ind are considered equal in comparisons right? That leads to confusion a lot of times.

 

Also what is the bit pattern you get in CVI if you do:

 

double doubleVar = NAN;

 

unsigned __int64 *test = (unsigned __int64 *) &doubleVar;

 

Then print *test as hexidecimal.

 

-Doug

Message 2 of 4
(4,504 Views)

Doug,

 

I wrote similar code in C++ and here is what I got:

C++ signaling NAN.png

 

__declspec(dllexport) void ReturnNAN(double *val)
{
	*val = std::numeric_limits<float>::quiet_NaN();
}
__declspec(dllexport) void ReturnSignalingNAN(double *val)
{
	*val = std::numeric_limits<float>::signaling_NaN();
}

 

I did the test you asked for in CVI and the bit pattern is 0x7FF8000000000000.

 

I guess I was just confused because the TestStand help seems to imply the opposite: that NAN is quiet and IND is signaling.

 

The reason this came up is that my customer is used to seeing NAN in their reports from LabVIEW modules, and when they tried to return NAN with CVI modules, they saw IND. I know that they are equal for comparison purposes (and I will reiterate that point to the customer...again), but they were upset that their logs had 'different' values displayed.

Josh W.
Certified TestStand Architect
Formerly blue
0 Kudos
Message 3 of 4
(4,470 Views)

It certainly does look like the documentation is incorrect or the implementation is incorrect. I'll submit a report.

 

-Doug

0 Kudos
Message 4 of 4
(4,460 Views)