提交 c57bbe79 编写于 作者: B br0 提交者: wangzelin.wzl

Fix greatest and least functions for bit type

上级 8064e195
...@@ -26,10 +26,12 @@ OB_INLINE int numeric_range_check( ...@@ -26,10 +26,12 @@ OB_INLINE int numeric_range_check(
const InType in_val, const OutType min_out_val, const OutType max_out_val, OutType& out_val) const InType in_val, const OutType min_out_val, const OutType max_out_val, OutType& out_val)
{ {
int ret = OB_SUCCESS; int ret = OB_SUCCESS;
if (in_val < static_cast<InType>(min_out_val)) { // Casting value from InType to OutType to prevent number overflow.
OutType cast_in_val = static_cast<OutType>(in_val);
if (cast_in_val < min_out_val) {
ret = OB_DATA_OUT_OF_RANGE; ret = OB_DATA_OUT_OF_RANGE;
out_val = min_out_val; out_val = min_out_val;
} else if (in_val > static_cast<InType>(max_out_val)) { } else if (cast_in_val > max_out_val) {
ret = OB_DATA_OUT_OF_RANGE; ret = OB_DATA_OUT_OF_RANGE;
out_val = max_out_val; out_val = max_out_val;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册