mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-23 04:41:11 +00:00
Bug 1918688 - Use standard headers for infinity, and float's max/min r=nbp,media-playback-reviewers,glandium,karlt
Still rely on mozilla aliases though, for readability and to avoid confusion in the case of NegativeInfinity. As a bonus, provide MaxNumberValue that mirrors MinNumberValue. Differential Revision: https://phabricator.services.mozilla.com/D222119
This commit is contained in:
parent
54a7d92d25
commit
f759d0da74
@ -65,6 +65,7 @@ using mozilla::Abs;
|
||||
using mozilla::AsciiAlphanumericToNumber;
|
||||
using mozilla::IsAsciiAlphanumeric;
|
||||
using mozilla::IsAsciiDigit;
|
||||
using mozilla::MaxNumberValue;
|
||||
using mozilla::Maybe;
|
||||
using mozilla::MinNumberValue;
|
||||
using mozilla::NegativeInfinity;
|
||||
@ -1447,7 +1448,7 @@ static const JSPropertySpec number_static_properties[] = {
|
||||
JSPROP_READONLY | JSPROP_PERMANENT),
|
||||
JS_DOUBLE_PS("NEGATIVE_INFINITY", mozilla::NegativeInfinity<double>(),
|
||||
JSPROP_READONLY | JSPROP_PERMANENT),
|
||||
JS_DOUBLE_PS("MAX_VALUE", 1.7976931348623157E+308,
|
||||
JS_DOUBLE_PS("MAX_VALUE", MaxNumberValue<double>(),
|
||||
JSPROP_READONLY | JSPROP_PERMANENT),
|
||||
JS_DOUBLE_PS("MIN_VALUE", MinNumberValue<double>(),
|
||||
JSPROP_READONLY | JSPROP_PERMANENT),
|
||||
|
@ -216,24 +216,14 @@ static MOZ_ALWAYS_INLINE int_fast16_t ExponentComponent(T aValue) {
|
||||
|
||||
/** Returns +Infinity. */
|
||||
template <typename T>
|
||||
static MOZ_ALWAYS_INLINE T PositiveInfinity() {
|
||||
/*
|
||||
* Positive infinity has all exponent bits set, sign bit set to 0, and no
|
||||
* significand.
|
||||
*/
|
||||
typedef FloatingPoint<T> Traits;
|
||||
return BitwiseCast<T>(Traits::kExponentBits);
|
||||
static constexpr MOZ_ALWAYS_INLINE T PositiveInfinity() {
|
||||
return std::numeric_limits<T>::infinity();
|
||||
}
|
||||
|
||||
/** Returns -Infinity. */
|
||||
template <typename T>
|
||||
static MOZ_ALWAYS_INLINE T NegativeInfinity() {
|
||||
/*
|
||||
* Negative infinity has all exponent bits set, sign bit set to 1, and no
|
||||
* significand.
|
||||
*/
|
||||
typedef FloatingPoint<T> Traits;
|
||||
return BitwiseCast<T>(Traits::kSignBit | Traits::kExponentBits);
|
||||
static constexpr MOZ_ALWAYS_INLINE T NegativeInfinity() {
|
||||
return -std::numeric_limits<T>::infinity();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -306,10 +296,14 @@ SpecificNaN(int signbit, typename FloatingPoint<T>::Bits significand) {
|
||||
|
||||
/** Computes the smallest non-zero positive float/double value. */
|
||||
template <typename T>
|
||||
static MOZ_ALWAYS_INLINE T MinNumberValue() {
|
||||
typedef FloatingPoint<T> Traits;
|
||||
typedef typename Traits::Bits Bits;
|
||||
return BitwiseCast<T>(Bits(1));
|
||||
static constexpr MOZ_ALWAYS_INLINE T MinNumberValue() {
|
||||
return std::numeric_limits<T>::denorm_min();
|
||||
}
|
||||
|
||||
/** Computes the largest positive float/double value. */
|
||||
template <typename T>
|
||||
static constexpr MOZ_ALWAYS_INLINE T MaxNumberValue() {
|
||||
return std::numeric_limits<T>::max();
|
||||
}
|
||||
|
||||
namespace detail {
|
||||
|
Loading…
Reference in New Issue
Block a user