RE: Uninitialized Variables
- Posted by Andy Serpa <renegade at earthling.net> Mar 24, 2002
- 428 views
jbrown1050 at yahoo.com wrote: > On 0, Andy Serpa <renegade at earthling.net> wrote: > > > > > > > I still don't understand what is wrong with > equal(x,nan) > > > > > > > > Simply, it doesn't work on my system. If it works > on yours, then that's > > a double-reason not to use it, as clearly it is > unpredictable. The > > other thread my have solved my problem, though -- > sprint(nan) returns > > "nan"! > > > Turns out sprint() is way slow. Here's my solution for now to detect inf's or nan's, which are effectively the same for my purposes: constant inf = 1e300 * 1e300 constant nan = -(inf/inf) constant inf_s = atom_to_float32(inf) constant inf_neg_s = atom_to_float32(-inf) constant nan_s = atom_to_float32(nan) constant nan_neg_s = atom_to_float32(-nan) constant bad_things = {inf_s, inf_neg_s, nan_s, nan_neg_s} type nan_or_inf(atom x) sequence x_seq x_seq = atom_to_float32(x) if find(x_seq, bad_things) then return 1 else return 0 end if end type Then, when I need to check, I just: if nan_or_inf(x) then...