RE: Uninitialized Variables

new topic     » goto parent     » topic index » view thread      » older message » newer message

jbrown1050 at yahoo.com wrote:
> 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.
> 

Yeah, that would work too.  I need to detect for either one of them, so 
I combined them.  If equal works with inf that is probably faster, 
you're right...

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu