浏览代码

Handle real::DEFAULT_BIGIT_COUNT changes a bit better.

Most operators do not yet handle reals of different sizes, but
this change fixes the most glaring bugs.
legacy
Sam Hocevar 7 年前
父节点
当前提交
c7c34312fe
共有 1 个文件被更改,包括 11 次插入2 次删除
  1. +11
    -2
      src/math/real.cpp

+ 11
- 2
src/math/real.cpp 查看文件

@@ -41,7 +41,15 @@ static real load_pi();
#define LOL_CONSTANT_GETTER(name, value) \
template<> real const& real::name() \
{ \
static real const ret = value; \
static real ret; \
static int prev_bigit_count = -1; \
/* If the default bigit count has changed, we must recompute
* the value with the desired precision. */ \
if (prev_bigit_count != DEFAULT_BIGIT_COUNT) \
{ \
ret = value; \
prev_bigit_count = DEFAULT_BIGIT_COUNT; \
} \
return ret; \
}

@@ -121,7 +129,8 @@ template<> real::Real(double d)
m_exponent = exponent - ((1 << 10) - 1);
m_mantissa.resize(DEFAULT_BIGIT_COUNT);
m_mantissa[0] = (bigit_t)(u.x >> 20);
m_mantissa[1] = (bigit_t)(u.x << 12);
if (m_mantissa.count() > 1)
m_mantissa[1] = (bigit_t)(u.x << 12);
break;
}
}


正在加载...
取消
保存