(svn r12573) -Codechange: use defined constants instead of numbers in math_func.hpp
authorsmatz
Fri, 04 Apr 2008 20:34:09 +0000
changeset 9321 3bc631f0ef34
parent 9320 029fe51fff1e
child 9322 0892ea4dea97
(svn r12573) -Codechange: use defined constants instead of numbers in math_func.hpp
src/core/math_func.hpp
src/stdafx.h
--- a/src/core/math_func.hpp	Fri Apr 04 20:03:49 2008 +0000
+++ b/src/core/math_func.hpp	Fri Apr 04 20:34:09 2008 +0000
@@ -163,8 +163,8 @@
  */
 static inline int32 ClampToI32(const int64 a)
 {
-	if (a <= (int32)0x80000000) return 0x80000000;
-	if (a >= (int32)0x7FFFFFFF) return 0x7FFFFFFF;
+	if (a <= INT32_MIN) return INT32_MIN;
+	if (a >= INT32_MAX) return INT32_MAX;
 	return (int32)a;
 }
 
@@ -177,7 +177,7 @@
  */
 static inline uint16 ClampToU16(const uint64 a)
 {
-	return (uint16)(a <= 0xFFFFU ? a : 0xFFFFU);
+	return (uint16)(a <= UINT16_MAX ? a : UINT16_MAX);
 }
 
 /**
--- a/src/stdafx.h	Fri Apr 04 20:03:49 2008 +0000
+++ b/src/stdafx.h	Fri Apr 04 20:34:09 2008 +0000
@@ -32,12 +32,15 @@
 		#include <stdint.h>
 	#endif
 #else
-	#define INT64_MAX (9223372036854775807LL)
-	#define INT64_MIN (-INT64_MAX - 1)
-	#define INT32_MAX (2147483647)
-	#define INT32_MIN (-INT32_MAX - 1)
-	#define INT16_MAX (32767)
-	#define INT16_MIN (-INT16_MAX - 1)
+	#define UINT64_MAX (18446744073709551615ULL)
+	#define INT64_MAX  (9223372036854775807LL)
+	#define INT64_MIN  (-INT64_MAX - 1)
+	#define UINT32_MAX (4294967295U)
+	#define INT32_MAX  (2147483647)
+	#define INT32_MIN  (-INT32_MAX - 1)
+	#define UINT16_MAX (65535U)
+	#define INT16_MAX  (32767)
+	#define INT16_MIN  (-INT16_MAX - 1)
 #endif
 
 #include <cstdio>