LibM: Add NAN macro

This commit is contained in:
Linus Groh 2020-06-04 13:03:15 +01:00 committed by Andreas Kling
parent d315281d56
commit 8a94813007
Notes: sideshowbarker 2024-07-19 05:50:39 +09:00
3 changed files with 5 additions and 3 deletions

View file

@ -32,6 +32,7 @@
#include <AK/Types.h>
#include <LibJS/Forward.h>
#include <LibJS/Runtime/Symbol.h>
#include <math.h>
// 2 ** 53 - 1
static constexpr double MAX_ARRAY_LIKE_INDEX = 9007199254740991.0;
@ -251,7 +252,7 @@ inline Value js_null()
inline Value js_nan()
{
return Value(__builtin_nan(""));
return Value(NAN);
}
inline Value js_infinity()

View file

@ -211,7 +211,7 @@ double log10(double x)
double log(double x)
{
if (x < 0)
return __builtin_nan("");
return NAN;
if (x == 0)
return -__builtin_huge_val();
double y = 1 + 2 * (x - 1) / (x + 1);
@ -321,7 +321,7 @@ double atan(double x)
double asin(double x)
{
if (x > 1 || x < -1)
return __builtin_nan("");
return NAN;
if (x > 0.5 || x < -0.5)
return 2 * atan(x / (1 + sqrt(1 - x * x)));
double squared = x * x;

View file

@ -31,6 +31,7 @@
__BEGIN_DECLS
#define HUGE_VAL 1e10000
#define NAN __builtin_nan("")
#define M_E 2.718281828459045
#define M_PI 3.141592653589793
#define M_PI_2 (M_PI / 2)