diff options
author | archshift <admin@archshift.com> | 2014-09-04 01:25:45 +0200 |
---|---|---|
committer | archshift <admin@archshift.com> | 2014-10-09 23:57:40 +0200 |
commit | f8d1e96ae7ac9a3483ff0a214796455946d7880f (patch) | |
tree | d54f1700231c510327e1e98042c3f21ddbe00ea6 /src/Globals.h | |
parent | DistortedHeightmap: Fixed crash on number rounding. (diff) | |
download | cuberite-f8d1e96ae7ac9a3483ff0a214796455946d7880f.tar cuberite-f8d1e96ae7ac9a3483ff0a214796455946d7880f.tar.gz cuberite-f8d1e96ae7ac9a3483ff0a214796455946d7880f.tar.bz2 cuberite-f8d1e96ae7ac9a3483ff0a214796455946d7880f.tar.lz cuberite-f8d1e96ae7ac9a3483ff0a214796455946d7880f.tar.xz cuberite-f8d1e96ae7ac9a3483ff0a214796455946d7880f.tar.zst cuberite-f8d1e96ae7ac9a3483ff0a214796455946d7880f.zip |
Diffstat (limited to 'src/Globals.h')
-rw-r--r-- | src/Globals.h | 40 |
1 files changed, 36 insertions, 4 deletions
diff --git a/src/Globals.h b/src/Globals.h index 0926457da..8bf7a0f0c 100644 --- a/src/Globals.h +++ b/src/Globals.h @@ -226,10 +226,10 @@ template class SizeChecker<UInt16, 2>; // CRT stuff: #include <sys/stat.h> -#include <assert.h> -#include <stdio.h> -#include <math.h> -#include <stdarg.h> +#include <cassert> +#include <cstdio> +#include <cmath> +#include <cstdarg> @@ -400,6 +400,38 @@ T Clamp(T a_Value, T a_Min, T a_Max) +/** Floors a_Value, then casts it to C (an int by default) */ +template <typename C = int> +C FloorD(double a_Value) +{ + return static_cast<C>(std::floor(a_Value)); +} + +/** Floors a_Value, then casts it to C (an int by default) */ +template <typename C = int> +C FloorF(double a_Value) +{ + return static_cast<C>(std::floorf(a_Value)); +} + +/** Ciels a_Value, then casts it to C (an int by default) */ +template <typename C = int> +C CeilD(double a_Value) +{ + return static_cast<C>(std::ceil(a_Value)); +} + +/** Ciels a_Value, then casts it to C (an int by default) */ +template <typename C = int> +C CeilF(double a_Value) +{ + return static_cast<C>(std::ceilf(a_Value)); +} + + + + + #ifndef TOLUA_TEMPLATE_BIND #define TOLUA_TEMPLATE_BIND(x) #endif |