util: Silent potential loss of precision warnings.

Also ensure multiplication doesn't happen for negative numbers.
This commit is contained in:
José Fonseca
2010-01-01 19:39:09 +00:00
parent 9595b59247
commit c852e960cc

View File

@@ -585,13 +585,12 @@ do { \
static INLINE uint32_t util_unsigned_fixed(float value, unsigned frac_bits)
{
value *= (1<<frac_bits);
return value < 0 ? 0 : value;
return value < 0 ? 0 : (uint32_t)(value * (1<<frac_bits));
}
static INLINE int32_t util_signed_fixed(float value, unsigned frac_bits)
{
return value * (1<<frac_bits);
return (int32_t)(value * (1<<frac_bits));
}