RE: Uninitialized Variables
- Posted by Andy Serpa <renegade at earthling.net> Mar 24, 2002
- 476 views
> If you don't mind me asking, what sorts of expressions are > your genes coming up with that yield NAN? Are you using > INF on occasion? Or square root of negative numbers? I'm > asking because, while this needs to be addressed (and so > far the discussion is very revealing,) it might save you time > if a workaround can be found. > I have simple checks to avoid division by zero, taking the log of a negative, etc., but if you mix a bunch of random mathmatical functions with a bunch of random values, you're going to get some strange results sometimes. The checks I have are all for *before* a function is performed. For instance, if the second argument is zero in a division, don't do the calculation. This will avoid an outright crash. Other functions, like tan(), will output nan or -nan if the value going in is too extreme. Since it doesn't actually crash, it would be much easier to check for a nan after the function is performed then try to set strict limits that must be checked before each individual function is performed. If I can check for nans reliably, I can just set up a custom "non_nan" type that catches it (a type that always returns TRUE to avoid a crash, but sets another global flag so I can throw out that function internally)...