Re: Uninitialized Variables
- Posted by jbrown1050 at yahoo.com Mar 24, 2002
- 476 views
On 0, Andy Serpa <renegade at earthling.net> wrote: > > 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... > You know, equal(x, inf) works fine for me. WHy not just have bad_things contain the nans only, and have an "is_nan" type? And if you really need it, why not have a seperate is_inf type? That would allow you to distingush them. I'm just wondering why you set it up this way, thats all. jbrown -- "Is there peace in heaven, or is that merely an illusion?" - Someone "May peace find its way through the heavens to the world of men and women before the fires of the damned consume them." - Someone Linux User:190064 Linux Machine:84163