| Index: src/utils.h
|
| diff --git a/src/utils.h b/src/utils.h
|
| index f95a136f96e6b0494057193d9f2da28e4faa8b86..0797d9977dbfce8059111f5f6158c392eea9f6bc 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 std::max(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 std::min(x, y);
|
| +}
|
|
|
| // Returns the absolute value of its argument.
|
| template <typename T>
|
|
|