From 908b2b3b951409cb5582da8b20dca6aea75d0947 Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Tue, 27 Sep 2011 17:09:21 +0000 Subject: [PATCH] real: fix a bug in the real number multiplication when one of the arguments is zero. --- src/real.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/real.cpp b/src/real.cpp index 94c29ed7..19c159c6 100644 --- a/src/real.cpp +++ b/src/real.cpp @@ -263,6 +263,13 @@ real real::operator *(real const &x) const { 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; int e = (m_signexp & 0x7fffffffu) - (1 << 30) + 1 + (x.m_signexp & 0x7fffffffu) - (1 << 30) + 1;