<br><br><div class="gmail_quote">2008/5/19 Glynn Clements <<a href="mailto:glynn@gclements.plus.com">glynn@gclements.plus.com</a>>:<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>
> I have some data that reads as "nan", while rare, it may happen when<br>
> compressing/uncompressing GRASS Locations to ship them across<br>
> Internet.<br>
><br>
> I would like to know how to deal with them in GRASS raster<br>
> programming, so that they are:<br>
> 1 - detected<br>
> 2 - set to null<br>
<br>
</div> if (x != x)<br>
G_set_d_null_value(&x, 1);<br>
</blockquote><div><br>Sounds simple enough.<br> </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>
<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'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's defined in <float.h> rather than <math.h>.<br>
</blockquote><div><br>hmm... ok<br><br> </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'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'll give it a try and see what it does here.<br> </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> </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 <<a href="mailto:glynn@gclements.plus.com">glynn@gclements.plus.com</a>><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>