Skip to content

Commit a35168b

Browse files
committed
FEAT: new native: NAN?
Returns TRUE if the number is Not-a-Number. Example: ``` >> nan? 1 == false >> nan? 1.#NaN == true >> nan? 1.0 / 0 == false >> nan? sin 2.0 == false >> nan? asin 2.0 == true ```
1 parent 9adf4b3 commit a35168b

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/core/n-math.c

+14
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,20 @@ enum {SINE, COSINE, TANGENT};
303303
return R_RET;
304304
}
305305

306+
/***********************************************************************
307+
**
308+
*/ REBNATIVE(nanq)
309+
/*
310+
// nan?: native [
311+
// {Returns TRUE if the number is Not-a-Number.}
312+
// value [number!]
313+
// ]
314+
***********************************************************************/
315+
{
316+
SET_LOGIC(D_RET, isnan(AS_DECIMAL(D_ARG(1))));
317+
return R_RET;
318+
}
319+
306320
#endif //!USE_NO_INFINITY
307321

308322

0 commit comments

Comments
 (0)