From 359c6fc4c4a861d2067604c5afbd706c87ab9048 Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Thu, 24 Aug 2017 19:14:16 +0200 Subject: [PATCH] Make the real number size a global variable (yuck). --- src/lol/math/real.h | 2 ++ src/math/real.cpp | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/lol/math/real.h b/src/lol/math/real.h index a76de606..bbba0573 100644 --- a/src/lol/math/real.h +++ b/src/lol/math/real.h @@ -214,6 +214,8 @@ private: bool m_sign, m_nan, m_inf; public: + static int DEFAULT_BIGIT_COUNT; + static inline int bigit_bits() { return 8 * sizeof(bigit_t); } inline int bigit_count() const { return m_mantissa.count(); } inline int total_bits() const { return bigit_count() * bigit_bits(); } diff --git a/src/math/real.cpp b/src/math/real.cpp index a0c848bc..df146517 100644 --- a/src/math/real.cpp +++ b/src/math/real.cpp @@ -77,7 +77,8 @@ LOL_CONSTANT_GETTER(R_SQRT1_2, R_SQRT2() / 2); * Now carry on with the rest of the Real class. */ -#define DEFAULT_SIZE 16 +template<> +int real::DEFAULT_BIGIT_COUNT = 16; template<> real::Real() : m_exponent(0), @@ -118,7 +119,7 @@ template<> real::Real(double d) /* Only works with 32-bit bigits for now */ static_assert(sizeof(bigit_t) == 4); m_exponent = exponent - ((1 << 10) - 1); - m_mantissa.resize(DEFAULT_SIZE); + m_mantissa.resize(DEFAULT_BIGIT_COUNT); m_mantissa[0] = (bigit_t)(u.x >> 20); m_mantissa[1] = (bigit_t)(u.x << 12); break;