Преглед на файлове

core: fix an accuracy error in sqrt() for arguments < 1.0.

legacy
Sam Hocevar sam преди 14 години
родител
ревизия
d9cb8f2961
променени са 1 файла, в които са добавени 4 реда и са изтрити 3 реда
  1. +4
    -3
      src/real.cpp

+ 4
- 3
src/real.cpp Целия файл

@@ -526,9 +526,10 @@ real sqrt(real const &x)
uint32_t sign = x.m_signexp & 0x80000000u;
ret.m_signexp = sign;

int exponent = (x.m_signexp & 0x7fffffffu) - ((1 << 30) - 1);
exponent = - (exponent / 2) + (v.x >> 23) - (u.x >> 23);
ret.m_signexp |= (exponent + ((1 << 30) - 1)) & 0x7fffffffu;
uint32_t exponent = (x.m_signexp & 0x7fffffffu);
exponent = ((1 << 30) + (1 << 29) -1) - (exponent + 1) / 2;
exponent = exponent + (v.x >> 23) - (u.x >> 23);
ret.m_signexp |= exponent & 0x7fffffffu;

/* Five steps of Newton-Raphson seems enough for 32-bigit reals. */
real three = 3;


Зареждане…
Отказ
Запис