Skip to content

Commit

Permalink
Cast to float to avoid compile error
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 694651495
  • Loading branch information
xnnpack-bot committed Nov 8, 2024
1 parent f81907b commit 4ea82e5
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/xnnpack/reference-utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Result round_float_to_int(float x) {
// avoid converting to an out of bounds integer. To avoid this problem, we've
// determined a constant that when added to the min/max float values, results
// in the upper bound of the integer range.
constexpr float half_mantissa = sizeof(Result) * 8 > 23 ? 128.0f : 0.0f;
constexpr int half_mantissa = sizeof(Result) * 8 > 23 ? 127 : 0;
x = std::max<float>(x, std::numeric_limits<Result>::min());
x = std::min<float>(x, std::numeric_limits<Result>::max() - half_mantissa);
return static_cast<Result>(x);
Expand Down

0 comments on commit 4ea82e5

Please sign in to comment.