Fix sign of division in cpp_int when the values are small enough to fit in a double_limb_type.

Add test cases for above.
Fixes #8126.

[SVN r83060]
This commit is contained in:
John Maddock
2013-02-21 13:05:41 +00:00
parent b8f6ed0612
commit 3111e69084
3 changed files with 27 additions and 0 deletions

View File

@@ -114,7 +114,10 @@ void divide_unsigned_helper(
if(r_order == 0)
{
if(result)
{
*result = px[0] / py[0];
result->sign(x.sign() != y.sign());
}
r = px[0] % py[0];
return;
}
@@ -126,7 +129,10 @@ void divide_unsigned_helper(
(static_cast<double_limb_type>(py[1]) << CppInt1::limb_bits) | py[0]
: py[0];
if(result)
{
*result = a / b;
result->sign(x.sign() != y.sign());
}
r = a % b;
return;
}