mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-21 03:55:24 +00:00
LibM: Add INFINITY macro
This commit is contained in:
parent
8a94813007
commit
ead76377b0
Notes:
sideshowbarker
2024-07-19 05:50:35 +09:00
Author: https://github.com/linusg Commit: https://github.com/SerenityOS/serenity/commit/ead76377b02 Pull-request: https://github.com/SerenityOS/serenity/pull/2496
3 changed files with 7 additions and 6 deletions
|
@ -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);
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue