(svn r12156) -Fix (r11454): Chance16I was now biased towards zero - round to nearest now
authorsmatz
Sat, 16 Feb 2008 00:46:38 +0000
changeset 9071 6790e9c11b5d
parent 9070 e83a2f017f3d
child 9072 6d250714e35d
(svn r12156) -Fix (r11454): Chance16I was now biased towards zero - round to nearest now
src/core/random_func.hpp
--- a/src/core/random_func.hpp	Sat Feb 16 00:10:03 2008 +0000
+++ b/src/core/random_func.hpp	Sat Feb 16 00:46:38 2008 +0000
@@ -88,7 +88,7 @@
 static inline bool Chance16I(const uint a, const uint b, const uint32 r)
 {
 	assert(b != 0);
-	return (uint16)r < (uint16)((a << 16) / b);
+	return (uint16)r < (uint16)(((a << 16) + b / 2) / b);
 }
 
 /**