LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Not A Number

I've a float variable which value is NaN ( 0x7F, 0xA00, 0x00,0x00 ) and which is displayed like "-Inf" inside a numeric ctrl instead of "NaN" . Why ?

How can I easely compare a float value to NaN, +Inf, -INF ?

Thank's.
0 Kudos
Message 1 of 4
(2,900 Views)
Hello

Inf, -Inf and Nan are actaully values that have been standardized by the IEEE, and this is what CVI uses to check it. You can test this by having something like the following:

float x=0.0;
x/=x;
SetCtrlVal (panelHandle, PANEL_NUMERIC, x);

This will set the numeric to display Nan. To find out more about how the numbers are setup, check out the following link:
IEEE Standard 754 Floating Point Numbers


I have attached a code snippet that will let you check for these values.

I hope this helps

Bilal Durrani
NI
Bilal Durrani
NI
Message 2 of 4
(2,900 Views)
That would be fine, except that it does not work. For the particular example you give, a CVI numeric control displays '-Inf', not 'NaN'. A bug, I expect.
--
Martin
Certified CVI Developer
0 Kudos
Message 3 of 4
(2,900 Views)
For the numeric box that is displaying the value, change the data type of the control to double. This should make it display Nan instead of -Inf. I suspect it might have been set to float for your control.

Thanks

Bilal
Bilal Durrani
NI
0 Kudos
Message 4 of 4
(2,900 Views)