summaryrefslogtreecommitdiffstats
path: root/src/gallium
diff options
context:
space:
mode:
authorJosé Fonseca <[email protected]>2010-01-01 19:39:09 +0000
committerJosé Fonseca <[email protected]>2010-01-02 00:01:42 +0000
commitc852e960ccb5d2727ccaaf2829e89596a6be3128 (patch)
tree579d93306d40338bbea03fde7268fe9cc181b3b7 /src/gallium
parent9595b59247518dbb7c47c25720dc2a5147973b0b (diff)
util: Silent potential loss of precision warnings.
Also ensure multiplication doesn't happen for negative numbers.
Diffstat (limited to 'src/gallium')
-rw-r--r--src/gallium/auxiliary/util/u_math.h5
1 files changed, 2 insertions, 3 deletions
diff --git a/src/gallium/auxiliary/util/u_math.h b/src/gallium/auxiliary/util/u_math.h
index 81aeb83cbb5..b2969a210a7 100644
--- a/src/gallium/auxiliary/util/u_math.h
+++ b/src/gallium/auxiliary/util/u_math.h
@@ -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));
}