Browse Source

Make the real number size a global variable (yuck).

legacy
Sam Hocevar 7 years ago
parent
commit
359c6fc4c4
2 changed files with 5 additions and 2 deletions
  1. +2
    -0
      src/lol/math/real.h
  2. +3
    -2
      src/math/real.cpp

+ 2
- 0
src/lol/math/real.h View File

@@ -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(); }


+ 3
- 2
src/math/real.cpp View File

@@ -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;


Loading…
Cancel
Save