Use standard binary multiple unit symbols for game size display.

Use integer math for the calculation as we cannot rely on floats for something as important as game size display!
This commit is contained in:
Jordan Woyak
2013-03-05 03:12:17 -06:00
parent 240238308c
commit 10d57a3402
2 changed files with 33 additions and 18 deletions

View File

@ -152,6 +152,28 @@ float MathFloatVectorSum(const std::vector<float>&);
#define ROUND_UP(x, a) (((x) + (a) - 1) & ~((a) - 1))
#define ROUND_DOWN(x, a) ((x) & ~((a) - 1))
template <typename T>
T Log2(T val)
{
#if defined(_M_X64)
T result;
asm
(
"bsr %1, %0"
: "=r"(result)
: "r"(val)
);
return result;
#else
T result = -1;
while (val != 0)
{
val >>= 1;
++result;
}
return result;
#endif
}
// Tiny matrix/vector library.
// Used for things like Free-Look in the gfx backend.