<br><br><div class="gmail_quote">2008/5/19 Glynn Clements &lt;<a href="mailto:glynn@gclements.plus.com">glynn@gclements.plus.com</a>&gt;:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="Ih2E3d"><br>
Yann Chemin wrote:<br>
<br>
&gt; I have some data that reads as &quot;nan&quot;, while rare, it may happen when<br>
&gt; compressing/uncompressing GRASS Locations to ship them across<br>
&gt; Internet.<br>
&gt;<br>
&gt; I would like to know how to deal with them in GRASS raster<br>
&gt; programming, so that they are:<br>
&gt; 1 - detected<br>
&gt; 2 - set to null<br>
<br>
</div> &nbsp; &nbsp; &nbsp; &nbsp;if (x != x)<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;G_set_d_null_value(&amp;x, 1);<br>
</blockquote><div><br>Sounds simple enough.<br>&nbsp;</div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br>
There is also isnan(), which is in C99, and also specified by POSIX:<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp;<a href="http://www.opengroup.org/onlinepubs/009695399/functions/isnan.html" target="_blank">http://www.opengroup.org/onlinepubs/009695399/functions/isnan.html</a><br>
<br>
However, I don&#39;t know if it exists on all platforms which we care<br>
about. MSDN says that MSVCRT has _isnan() (with a leading underscore),<br>
but it&#39;s defined in &lt;float.h&gt; rather than &lt;math.h&gt;.<br>
</blockquote><div><br>hmm... ok<br><br>&nbsp;</div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br>
The (x != x) test should be portable; OTOH, it&#39;s the kind of thing<br>
that compilers often get wrong, particularly when optimising (if you<br>
ignore NaN, x!=x is always false).<br>
</blockquote><div><br>OK, this is a pickle... I&#39;ll give it a try and see what it does here.<br>&nbsp;</div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
For 7.0, I intend to change G_is_[fd]_null_value() to treat all NaN<br>
values as null, not just the specific bit patterns which it currently<br>
uses.<br>
<font color="#888888"></font></blockquote><div><br>This would be good indeed. <br>&nbsp;</div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><font color="#888888"><br>

--<br>
Glynn Clements &lt;<a href="mailto:glynn@gclements.plus.com">glynn@gclements.plus.com</a>&gt;<br>
</font></blockquote></div><br><br clear="all"><br>-- <br>Yann Chemin<br>International Rice Research Institute<br>Office: <a href="http://www.irri.org/gis">http://www.irri.org/gis</a><br>Perso: <a href="http://www.freewebs.com/ychemin">http://www.freewebs.com/ychemin</a>