summaryrefslogtreecommitdiff
path: root/Libraries
diff options
context:
space:
mode:
authorLinus Groh <mail@linusgroh.de>2020-06-04 13:05:27 +0100
committerAndreas Kling <kling@serenityos.org>2020-06-04 15:45:11 +0200
commitead76377b025eb69b9918f6b71c1539c3e233f40 (patch)
treea602bae4cf7b61fc570be5c289a698c9c716d5bd /Libraries
parent8a94813007ecf009a4ffa4e9851211f7b0d03fec (diff)
downloadserenity-ead76377b025eb69b9918f6b71c1539c3e233f40.zip
LibM: Add INFINITY macro
Diffstat (limited to 'Libraries')
-rw-r--r--Libraries/LibJS/Runtime/Value.h8
-rw-r--r--Libraries/LibM/math.cpp4
-rw-r--r--Libraries/LibM/math.h1
3 files changed, 7 insertions, 6 deletions
diff --git a/Libraries/LibJS/Runtime/Value.h b/Libraries/LibJS/Runtime/Value.h
index 4fc78516f0..cb3e1c5835 100644
--- a/Libraries/LibJS/Runtime/Value.h
+++ b/Libraries/LibJS/Runtime/Value.h
@@ -76,8 +76,8 @@ public:
bool is_infinity() const { return is_number() && __builtin_isinf(as_double()); }
bool is_positive_infinity() const { return is_number() && __builtin_isinf_sign(as_double()) > 0; }
bool is_negative_infinity() const { return is_number() && __builtin_isinf_sign(as_double()) < 0; }
- bool is_positive_zero() const { return is_number() && 1.0 / as_double() == __builtin_huge_val(); }
- bool is_negative_zero() const { return is_number() && 1.0 / as_double() == -__builtin_huge_val(); }
+ bool is_positive_zero() const { return is_number() && 1.0 / as_double() == INFINITY; }
+ bool is_negative_zero() const { return is_number() && 1.0 / as_double() == -INFINITY; }
bool is_integer() const { return is_finite_number() && (i32)as_double() == as_double(); }
bool is_finite_number() const
{
@@ -257,12 +257,12 @@ inline Value js_nan()
inline Value js_infinity()
{
- return Value(__builtin_huge_val());
+ return Value(INFINITY);
}
inline Value js_negative_infinity()
{
- return Value(-__builtin_huge_val());
+ return Value(-INFINITY);
}
Value greater_than(Interpreter&, Value lhs, Value rhs);
diff --git a/Libraries/LibM/math.cpp b/Libraries/LibM/math.cpp
index 77d385ab43..33e05047fe 100644
--- a/Libraries/LibM/math.cpp
+++ b/Libraries/LibM/math.cpp
@@ -213,7 +213,7 @@ double log(double x)
if (x < 0)
return NAN;
if (x == 0)
- return -__builtin_huge_val();
+ return -INFINITY;
double y = 1 + 2 * (x - 1) / (x + 1);
double exponentiated = exp(y);
y = y + 2 * (x - exponentiated) / (x + exponentiated);
@@ -257,7 +257,7 @@ double exp(double exponent)
if (integer_part & 32)
result *= e_to_power<32>();
if (integer_part >= 64)
- return __builtin_huge_val();
+ return INFINITY;
}
exponent -= integer_part;
} else if (exponent < 0)
diff --git a/Libraries/LibM/math.h b/Libraries/LibM/math.h
index 5a4de08eac..ed738b356b 100644
--- a/Libraries/LibM/math.h
+++ b/Libraries/LibM/math.h
@@ -31,6 +31,7 @@
__BEGIN_DECLS
#define HUGE_VAL 1e10000
+#define INFINITY __builtin_huge_val()
#define NAN __builtin_nan("")
#define M_E 2.718281828459045
#define M_PI 3.141592653589793