From 71cd0199fda68a84c5f9a5252bf63e69712b177b Mon Sep 17 00:00:00 2001 From: "madmaxoft@gmail.com" Date: Wed, 27 Feb 2013 10:01:20 +0000 Subject: Made FAST_FLOOR_DIV work correctly, replaced all floorf() divisions with it. Still not perfect - chunk and region calculations can be made into a single CPU instruction - SAR - but not all compilers are known to support that (">>" operator on signed datatypes needs to perform arithmetic shift, C/C++ standard makes it implementation-specific; MSVC and GCC do what we need, LLVM unknown) git-svn-id: http://mc-server.googlecode.com/svn/trunk@1224 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- source/Globals.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source/Globals.h') diff --git a/source/Globals.h b/source/Globals.h index e536559dd..958c6d6ae 100644 --- a/source/Globals.h +++ b/source/Globals.h @@ -189,9 +189,10 @@ typedef unsigned short UInt16; /// Allows arithmetic expressions like "32 KiB" (but consider using parenthesis around it, "(32 KiB)" ) #define KiB * 1024 +#define MiB * 1024 * 1024 /// Faster than (int)floorf((float)x / (float)div) -#define FAST_FLOOR_DIV( x, div ) ( (x) < 0 ? (((int)x / div) - 1) : ((int)x / div) ) +#define FAST_FLOOR_DIV( x, div ) (((x) - (((x) < 0) ? ((div) - 1) : 0)) / (div)) // Own version of assert() that writes failed assertions to the log for review #ifdef _DEBUG -- cgit v1.2.3