RE: Uninitialized Variables

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

> 
> Apparently NAN is (silly me) Not A Number! :P
> using equal() compares NAN properly and consistently
> 
> Here is my revised uninitialized values for variables:
> 
>    integer  = -INF
>    atom     =  INF
>    sequence =  NAN
>    object   = -NAN
> 

So how do I test if something is a nan?  The "official" way is to use 
x!=x, but that is usually optimized away by most compilers (& Euphoria, 
apparently.)  Using something like if x=1 and x=2 will work in the 
interpreter, but not translated to C, even with Watcom.  (In fact, it is 
different depending on the compiler).

Am I stuck with "if x and compare(x/x,1)"?

For my genetic programming system this is a very real problem, as it 
comes up with random mathmatical expressions that sometimes are nan's.  
If you then take a predicted value (which is a nan) as output for a 
function that it has created and compare it with a target value, it will 
show as being equal (& therefore error = 0).  So functions with nan's as 
output get the highest fitness, which is a disaster...

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

Search



Quick Links

User menu

Not signed in.

Misc Menu