(svn r17292) -Codechange: use unified ToPercent() function to convert fract numbers to percents

This commit is contained in:
smatz
2009-08-27 13:31:26 +00:00
parent 3af095aa19
commit a0d0206f2d
9 changed files with 58 additions and 36 deletions

View File

@@ -269,6 +269,28 @@ static FORCEINLINE void Swap(T &a, T &b)
b = t;
}
/**
* Converts a "fract" value 0..255 to "percent" value 0..100
* @param i value to convert, range 0..255
* @return value in range 0..100
*/
static FORCEINLINE uint ToPercent8(uint i)
{
assert(i < 256);
return i * 101 >> 8;
}
/**
* Converts a "fract" value 0..65535 to "percent" value 0..100
* @param i value to convert, range 0..65535
* @return value in range 0..100
*/
static FORCEINLINE uint ToPercent16(uint i)
{
assert(i < 65536);
return i * 101 >> 16;
}
int LeastCommonMultiple(int a, int b);
int GreatestCommonDivisor(int a, int b);