Changeset 1000


Ignore:
Timestamp:
Oct 3, 2011, 1:36:22 AM (11 years ago)
Author:
sam
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/real.cpp

    r999 r1000  
    527527    ret.m_signexp = sign;
    528528
    529     int exponent = (x.m_signexp & 0x7fffffffu) - ((1 << 30) - 1);
    530     exponent = - (exponent / 2) + (v.x >> 23) - (u.x >> 23);
    531     ret.m_signexp |= (exponent + ((1 << 30) - 1)) & 0x7fffffffu;
     529    uint32_t exponent = (x.m_signexp & 0x7fffffffu);
     530    exponent = ((1 << 30) + (1 << 29) -1) - (exponent + 1) / 2;
     531    exponent = exponent + (v.x >> 23) - (u.x >> 23);
     532    ret.m_signexp |= exponent & 0x7fffffffu;
    532533
    533534    /* Five steps of Newton-Raphson seems enough for 32-bigit reals. */
Note: See TracChangeset for help on using the changeset viewer.