Browse Source

real: fix a bug in the real number multiplication when one of the arguments

is zero.
legacy
Sam Hocevar sam 13 years ago
parent
commit
908b2b3b95
1 changed files with 7 additions and 0 deletions
  1. +7
    -0
      src/real.cpp

+ 7
- 0
src/real.cpp View File

@@ -263,6 +263,13 @@ real real::operator *(real const &x) const
{ {
real ret; real ret;


if (m_signexp << 1 == 0 || x.m_signexp << 1 == 0)
{
ret = (m_signexp << 1 == 0) ? *this : x;
ret.m_signexp ^= x.m_signexp & 0x80000000u;
return ret;
}

ret.m_signexp = (m_signexp ^ x.m_signexp) & 0x80000000u; ret.m_signexp = (m_signexp ^ x.m_signexp) & 0x80000000u;
int e = (m_signexp & 0x7fffffffu) - (1 << 30) + 1 int e = (m_signexp & 0x7fffffffu) - (1 << 30) + 1
+ (x.m_signexp & 0x7fffffffu) - (1 << 30) + 1; + (x.m_signexp & 0x7fffffffu) - (1 << 30) + 1;


Loading…
Cancel
Save