NaN traps

Norman Diamond diamond at csl.sony.co.jp
Mon Sep 18 20:37:03 AEST 1989


In article <14344 at bloom-beacon.MIT.EDU> tada at athena.mit.edu (Michael J Zehr) writes:

>I once wasted a lot of code dealing with something like:
>  if (data == 0) {zero_cnt++; continue;}
>  if NaN(data) {nan_cnt++; continue;}
>  do_something(data);
>if data was a bit pattern which was invalid, the
>comparison of it to 0 would change it's value to a particular number!!!

That seems like a somewhat illegal implementation.  I don't see an
"&" in front of data, and you didn't say you're using C++.  So the
NaN function can only get its hands on a COPY of data, and change
its COPY to a different value (according to K&R-*, ANSI, Version 6, etc.)

--
-- 
Norman Diamond, Sony Corporation (diamond at ws.sony.junet)
  The above opinions are inherited by your machine's init process (pid 1),
  after being disowned and orphaned.  However, if you see this at Waterloo or
  Anterior, then their administrators must have approved of these opinions.



More information about the Comp.lang.c mailing list