PcmUtils: make PcmClamp() 64-bit-safe, add missing cast

This commit is contained in:
Max Kellermann 2013-02-01 14:04:40 +01:00
parent 469e233428
commit 0ac06d77f1
1 changed files with 2 additions and 2 deletions

View File

@ -71,8 +71,8 @@ gcc_const
static inline T static inline T
PcmClamp(U x) PcmClamp(U x)
{ {
constexpr U MIN_VALUE = -(1 << (bits - 1)); constexpr U MIN_VALUE = -(U(1) << (bits - 1));
constexpr U MAX_VALUE = (1 << (bits - 1)) - 1; constexpr U MAX_VALUE = (U(1) << (bits - 1)) - 1;
typedef std::numeric_limits<T> limits; typedef std::numeric_limits<T> limits;
static_assert(MIN_VALUE >= limits::min(), "out of range"); static_assert(MIN_VALUE >= limits::min(), "out of range");