LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

NaN becomes -Inf in a table or graph

LabWindows 6.0

I read in float data sets from a text file, and when I encounter a NaN string I convert the resulting float to NaN by (float)sqrt(-1); The resulting variable converted has the value 0xFFC00000, and shows up as NaN when I put the mouse over it in break mode. When I save this variable back to a text file with fprintf(,"%f",) it is saved as "NaN", so the value really seems to be NaN. So far so good.

However, when I put this variable into a table, it shows up as -Inf. Printed in a graph (as a member of an array) it also behaves like -Inf. When, in break mode, I use "View variable value" it still says "NaN" in the second field. BUT... when I select the variable and then use the "view memory display" function, it says -Inf when the format mode is "floats" but FFC00000 when the format mode is "hex longs".

Is there a conversion bug somewhere, or am I missing something?

Erwin Timmerman
0 Kudos
Message 1 of 3
(3,347 Views)
Erwin,

Could you post a small example that shows this behaviour then I can take a furter look at it.

Met vriendelijke groet / Kind regards,

Karsten
Applications Engineer
National Instruments
0 Kudos
Message 2 of 3
(3,319 Views)
Erwin,

There are a couple of factors that are causing the behavior you're seeing.

1. At the time CVI 6.0 was developed, there was a bug in the Microsoft compiler that caused NaN values to incorrectly be coerced to +Inf or -Inf, sometimes. Microsoft fixed this bug when they released Visual Studio.NET 2003, and as result the problem went away with CVI 7.1. This accounts for what you are seeing with numeric controls and tables (including the memory display, which uses a table control).

2. The situation with graphs is different. Up until CVI 6.0, graphs did not distinguish between NaN, -Inf and +Inf. All would show up as a very large spike in the plot. Starting with CVI 7.0, the graph control starting making this distinction, and as a result, NaNs would show up as gaps in the plot. However, there's still a catch (there's always a catch :-)) in the process of investigating this issue, I noticed that the detection is not working when the data type of the plot is VAL_FLOAT instead of the more common VAL_DOUBLE. This bug will be fixed for CVI 8.0.

So that's where things stand right now. To summarize: if you upgrade to CVI 7.1, you can fix all aspects of your problem, as long as you plot doubles instead of floats.

Hope this helps

Luis
NI
Message 3 of 3
(3,299 Views)