Commit 348568d4 authored by Yedidya Feldblum's avatar Yedidya Feldblum Committed by Facebook GitHub Bot

use lowest() in numeric traits

Summary:
The numeric functions `less_than` and `greater_than` are intended for integer use but, technically, they are not constrained to integer use. If they are used with floating-point types, `min()` does not do the expected thing so use use `lowest()`.

Fixes: https://github.com/facebook/folly/issues/1604.

Reviewed By: iahs

Differential Revision: D29069620

fbshipit-source-id: 369bd59338b889cb1ec0f56d232a3775500573d0
parent 5c8255f7
......@@ -727,7 +727,7 @@ bool less_than_impl(LHS const lhs) {
(!std::is_signed<RHS>::value && is_negative(lhs)) ? true :
(!std::is_signed<LHS>::value && is_negative(rhs)) ? false :
rhs > std::numeric_limits<LHS>::max() ? true :
rhs <= std::numeric_limits<LHS>::min() ? false :
rhs <= std::numeric_limits<LHS>::lowest() ? false :
lhs < rhs;
// clang-format on
}
......@@ -740,7 +740,7 @@ bool greater_than_impl(LHS const lhs) {
(!std::is_signed<RHS>::value && is_negative(lhs)) ? false :
(!std::is_signed<LHS>::value && is_negative(rhs)) ? true :
rhs > std::numeric_limits<LHS>::max() ? false :
rhs < std::numeric_limits<LHS>::min() ? true :
rhs < std::numeric_limits<LHS>::lowest() ? true :
lhs > rhs;
// clang-format on
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment