diff options
author | AnotherTest <ali.mpfard@gmail.com> | 2020-07-12 03:27:42 +0430 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-07-12 01:19:48 +0200 |
commit | 9054811ace1ad3b1e84da49964d1a4b87e6e7948 (patch) | |
tree | 9ec3957d49d8136922ee217172dcec3386c9f424 /Libraries | |
parent | 8a94622e548027744c98c366c9cf8981f761aa0a (diff) | |
download | serenity-9054811ace1ad3b1e84da49964d1a4b87e6e7948.zip |
LibM: Add 'isnormal'
Diffstat (limited to 'Libraries')
-rw-r--r-- | Libraries/LibM/math.cpp | 7 | ||||
-rw-r--r-- | Libraries/LibM/math.h | 5 |
2 files changed, 12 insertions, 0 deletions
diff --git a/Libraries/LibM/math.cpp b/Libraries/LibM/math.cpp index ffa6483ccb..fc1e1ec38a 100644 --- a/Libraries/LibM/math.cpp +++ b/Libraries/LibM/math.cpp @@ -536,4 +536,11 @@ double erfc(double x) { return 1 - erf(x); } + +int isnormal(double x) +{ + if (x < 0) + x = -x; + return x >= DOUBLE_MIN && x <= DOUBLE_MAX; +} } diff --git a/Libraries/LibM/math.h b/Libraries/LibM/math.h index 36b971560f..2783f1af59 100644 --- a/Libraries/LibM/math.h +++ b/Libraries/LibM/math.h @@ -42,6 +42,9 @@ __BEGIN_DECLS #define M_SQRT2 1.4142135623730951 #define M_SQRT1_2 0.7071067811865475 +#define DOUBLE_MAX ((double)0b0111111111101111111111111111111111111111111111111111111111111111) +#define DOUBLE_MIN ((double)0b0000000000010000000000000000000000000000000000000000000000000000) + double acos(double); float acosf(float); double asin(double); @@ -110,4 +113,6 @@ double hypot(double, double); double erf(double); double erfc(double); +int isnormal(double); + __END_DECLS |