summaryrefslogtreecommitdiffstats
path: root/source/core
diff options
context:
space:
mode:
Diffstat (limited to 'source/core')
-rw-r--r--source/core/slang-math.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/source/core/slang-math.h b/source/core/slang-math.h
index 0daad0d5a..fa7eea6be 100644
--- a/source/core/slang-math.h
+++ b/source/core/slang-math.h
@@ -5,6 +5,13 @@
namespace Slang
{
+ // Some handy constants
+
+ // The largest positive (or negative) number
+# define SLANG_HALF_MAX 65504.0f
+ // Smallest (denormalized) value. 1 / 2^24
+# define SLANG_HALF_SUB_NORMAL_MIN (1.0f / 16777216.0f)
+
class Math
{
public:
@@ -20,6 +27,13 @@ namespace Slang
static const float Pi;
+
+ template <typename T>
+ static T Abs(T a)
+ {
+ return (a < 0) ? -a : a;
+ }
+
template<typename T>
static T Min(const T& v1, const T&v2)
{