Hello Ge, I was wondering if it would be possible to include some method of determining if a function returns 'nan'? In working with fractals, some of the results that I get during a search for a new parameter set may produce a 'nan' value, but there seems to be no way of testing for that condition. As a result of this, several classes of fractals that I am working on don't complete a search because I can't test for this. I was thinking how this might go, and there were basically two forms that could work... // static constant if (result == math.nan) { doSomethingWith(result); } else { reportError(result); } or // a function call if ((result) => math.isNan) { ... Thanks, Mike
Hi Mike!
I was wondering if it would be possible to include some method of determining if a function returns 'nan'?
This is a great idea. Added and committed to CVS. int math.isinf( float ) int math.isnan( float ) Also adding examples/basic/infnan.ck // big number 1000000000000000000000000000.0 => float n; // overflow it repeat( 20 ) n *=> n; // test it <<< math.isinf( n ) >>>; // bye sanity 0 *=> n; // test it <<< math.isnan( n ) >>>; // more <<< 1.0 / 0.0 => math.isinf >>>; <<< 0.0 / 0.0 => math.isnan >>>; So far, this seems portable on osx, linux, win32. We will see if and how it breaks under different systems as we go. Best, Ge!
Thanks, Ge. It is starting to sound like the next release can't come
soon enough...
Guess I will just have to figure out how to compile from the CVS
stuff... only to be on the bleeding edge...
Mike
On 2/8/06, Ge Wang
Hi Mike!
I was wondering if it would be possible to include some method of determining if a function returns 'nan'?
This is a great idea. Added and committed to CVS.
int math.isinf( float ) int math.isnan( float )
Also adding examples/basic/infnan.ck
// big number 1000000000000000000000000000.0 => float n; // overflow it repeat( 20 ) n *=> n; // test it <<< math.isinf( n ) >>>; // bye sanity 0 *=> n; // test it <<< math.isnan( n ) >>>;
// more <<< 1.0 / 0.0 => math.isinf >>>; <<< 0.0 / 0.0 => math.isnan >>>;
So far, this seems portable on osx, linux, win32. We will see if and how it breaks under different systems as we go.
Best, Ge!
_______________________________________________ chuck-users mailing list chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
-- Help the Environment, Plant a Bush back in Texas!
participants (2)
-
Ge Wang
-
Mike McGonagle