mirror of
https://github.com/BelfrySCAD/BOSL2.git
synced 2024-12-29 16:29:40 +00:00
Added NAN, INF, and is_nan().
This commit is contained in:
parent
28f07a997f
commit
ba032e2f4d
3 changed files with 17 additions and 1 deletions
12
common.scad
12
common.scad
|
@ -73,6 +73,18 @@ function is_int(n) = is_num(n) && n == round(n);
|
|||
function is_integer(n) = is_num(n) && n == round(n);
|
||||
|
||||
|
||||
// Function: is_nan()
|
||||
// Usage:
|
||||
// is_nan(x);
|
||||
// Description:
|
||||
// Returns true if a given value `x` is nan, a floating point value representing "not a number".
|
||||
// This test is far more complicated than it should be, because while arguable correct, the tests
|
||||
// `is_num(nan)` and `nan==nan` both returns false.
|
||||
function is_nan(x) =
|
||||
!is_num(x) && !is_undef(x) && !is_string(x) &&
|
||||
!is_list(x) && !(x<=INF) && is_undef(x[0]);
|
||||
|
||||
|
||||
|
||||
// Section: Handling `undef`s.
|
||||
|
||||
|
|
|
@ -14,6 +14,10 @@ PHI = (1+sqrt(5))/2; // The golden ratio phi.
|
|||
|
||||
EPSILON = 1e-9; // A really small value useful in comparing FP numbers. ie: abs(a-b)<EPSILON
|
||||
|
||||
INF = 1/0; // The value `inf`, useful for comparisons.
|
||||
|
||||
NAN = acos(2); // The value `nan`, useful for comparisons.
|
||||
|
||||
|
||||
|
||||
// Section: Simple math
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
BOSL_VERSION = [2,0,116];
|
||||
BOSL_VERSION = [2,0,117];
|
||||
|
||||
|
||||
// Section: BOSL Library Version Functions
|
||||
|
|
Loading…
Reference in a new issue