Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to distinguish different types of NaN float in Python
    text
    copied!<p>I'm writing Python 2.6 code that interfaces with <a href="http://www.ni.com/teststand/" rel="noreferrer">NI TestStand</a> 4.2 via COM in Windows. I want to make a "NAN" value for a variable, but if I pass it <code>float('nan')</code>, TestStand displays it as <code>IND</code>.</p> <p>Apparently TestStand distinguishes between floating point "IND" and "NAN" values. According to <a href="http://zone.ni.com/reference/en-XX/help/370052H-01/tssuppref/infotopics/special_constant_values/" rel="noreferrer">TestStand help</a>:</p> <ul> <li><code>IND</code> corresponds to <em>Signaling NaN</em> in Visual C++, while</li> <li><code>NAN</code> corresponds to <em>QuietNaN</em></li> </ul> <p>That implies that Python's <code>float('nan')</code> is effectively a <em>Signaling NaN</em> when passed through COM. However, from what I've read about <em>Signaling NaN</em>, it seems that <em>Signaling NaN</em> is a bit "exotic" and <em>Quiet NaN</em> is your "regular" NaN. So I have my doubts that Python would be passing a <em>Signaling NaN</em> through COM. <strong>How could I find out if a Python <code>float('nan')</code> is passed through COM as a <em>Signaling NaN</em> or <em>Quiet NaN</em>, or maybe <em>Indeterminate</em>?</strong></p> <p>Is there any way to make a <em>Signaling NaN</em> versus <em>QuietNaN</em> or <em>Indeterminate</em> in Python, when interfacing with other languages? (Using <code>ctypes</code> perhaps?) I assume this would be a platform-specific solution, and I'd accept that in this case.</p> <p><strong>Update:</strong> In the TestStand sequence editor, I tried making two variables, one set to <code>NAN</code> and the other set to <code>IND</code>. Then I saved it to a file. Then I opened the file and read each variable using Python. In both cases, Python reads them as a <code>nan</code> float.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload