| Index: src/utils.h
|
| diff --git a/src/utils.h b/src/utils.h
|
| index a58439971f4c1f5ac291c7188a703a5b404946e3..8eca39207d4aa55b222870a2e36e7ce53a273bc8 100644
|
| --- a/src/utils.h
|
| +++ b/src/utils.h
|
| @@ -200,6 +200,23 @@ T Min(T a, T b) {
|
| return a < b ? a : b;
|
| }
|
|
|
| +// Returns the maximum of the two parameters according to JavaScript semantics.
|
| +template <typename T>
|
| +T JSMax(T x, T y) {
|
| + if (std::isnan(x)) return x;
|
| + if (std::isnan(y)) return y;
|
| + if (std::signbit(x) < std::signbit(y)) return x;
|
| + return x > y ? x : y;
|
| +}
|
| +
|
| +// Returns the maximum of the two parameters according to JavaScript semantics.
|
| +template <typename T>
|
| +T JSMin(T x, T y) {
|
| + if (std::isnan(x)) return x;
|
| + if (std::isnan(y)) return y;
|
| + if (std::signbit(x) < std::signbit(y)) return y;
|
| + return x > y ? y : x;
|
| +}
|
|
|
| // Returns the absolute value of its argument.
|
| template <typename T>
|
|
|