Ver código fonte

Temporary fix for real::sqrt() which I broke recently.

legacy
Sam Hocevar 7 anos atrás
pai
commit
1c27691ef9
1 arquivos alterados com 2 adições e 2 exclusões
  1. +2
    -2
      src/math/real.cpp

+ 2
- 2
src/math/real.cpp Ver arquivo

@@ -726,12 +726,12 @@ template<> real sqrt(real const &x)
ret.m_mantissa.resize(x.m_mantissa.count());
ret.m_mantissa[0] = v.x << 9;

/* FIXME: check this, it’s been a long time… */
/* FIXME FIXME FIXME: this is broken */
ret.m_exponent = -x.m_exponent / 2 + (v.x >> 23) - (u.x >> 23);

/* FIXME: 1+log2(bigit_count()) steps of Newton-Raphson seems to be enough for
* convergence, but this hasn't been checked seriously. */
for (int i = 1; i <= x.bigit_count(); i *= 2)
for (int i = 1; i <= 1024 * x.bigit_count(); i *= 2)
{
ret = ret * (real::R_3() - ret * ret * x);
--ret.m_exponent;


Carregando…
Cancelar
Salvar