mirror of
https://github.com/boostorg/multiprecision.git
synced 2026-07-21 13:23:49 +00:00
Correct eval_increment corner case.
Fixes https://github.com/boostorg/multiprecision/issues/277.
This commit is contained in:
@@ -263,7 +263,7 @@ eval_increment(cpp_int_backend<MinBits1, MaxBits1, SignType1, Checked1, Allocato
|
|||||||
else if (result.sign() && result.limbs()[0])
|
else if (result.sign() && result.limbs()[0])
|
||||||
{
|
{
|
||||||
--result.limbs()[0];
|
--result.limbs()[0];
|
||||||
if (!result.limbs()[0])
|
if (!result.limbs()[0] && (result.size() == 1))
|
||||||
result.sign(false);
|
result.sign(false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -1024,6 +1024,7 @@ test-suite misc :
|
|||||||
[ run git_issue_175.cpp ]
|
[ run git_issue_175.cpp ]
|
||||||
[ run git_issue_248.cpp ]
|
[ run git_issue_248.cpp ]
|
||||||
[ run git_issue_265.cpp : : : [ check-target-builds ../config//has_mpfr : <source>gmp <source>mpfr : <build>no ] ]
|
[ run git_issue_265.cpp : : : [ check-target-builds ../config//has_mpfr : <source>gmp <source>mpfr : <build>no ] ]
|
||||||
|
[ run git_issue_277.cpp ]
|
||||||
[ compile git_issue_98.cpp :
|
[ compile git_issue_98.cpp :
|
||||||
[ check-target-builds ../config//has_float128 : <define>TEST_FLOAT128 <source>quadmath : ]
|
[ check-target-builds ../config//has_float128 : <define>TEST_FLOAT128 <source>quadmath : ]
|
||||||
[ check-target-builds ../config//has_gmp : <define>TEST_GMP <source>gmp : ]
|
[ check-target-builds ../config//has_gmp : <define>TEST_GMP <source>gmp : ]
|
||||||
|
|||||||
@@ -0,0 +1,40 @@
|
|||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Copyright 2019 John Maddock. Distributed under the Boost
|
||||||
|
// Software License, Version 1.0. (See accompanying file
|
||||||
|
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
|
#include <boost/multiprecision/cpp_int.hpp>
|
||||||
|
#include "test.hpp"
|
||||||
|
|
||||||
|
template <class I>
|
||||||
|
void test()
|
||||||
|
{
|
||||||
|
I val(1);
|
||||||
|
val <<= 512;
|
||||||
|
I t(val);
|
||||||
|
++t;
|
||||||
|
BOOST_CHECK_EQUAL(t - val, 1);
|
||||||
|
--t;
|
||||||
|
BOOST_CHECK_EQUAL(t, val);
|
||||||
|
--t;
|
||||||
|
BOOST_CHECK_EQUAL(val - t, 1);
|
||||||
|
|
||||||
|
val = -val;
|
||||||
|
t = val;
|
||||||
|
--t;
|
||||||
|
BOOST_CHECK_EQUAL(t - val, -1);
|
||||||
|
++t;
|
||||||
|
BOOST_CHECK_EQUAL(t, val);
|
||||||
|
++t;
|
||||||
|
BOOST_CHECK_EQUAL(val - t, -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
test<boost::multiprecision::cpp_int>();
|
||||||
|
test<boost::multiprecision::int1024_t>();
|
||||||
|
test<boost::multiprecision::checked_int1024_t>();
|
||||||
|
return boost::report_errors();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user