Boost logo

Boost :

Subject: [boost] [mp_math] Wrong sign for mp_int<> after addition.
From: Jeroen N. Witmond (jnw_at_[hidden])
Date: 2009-01-16 11:20:48


Greetings,

I posted this in the Boost Users list last Sunday, but on second throught
perhaps I'd beter post it here.

I've stumbled across a problem in mp_math in the sandbox, revision 50541. The
code below (a Boost.Test test case) demonstrates that the problem is present
only for mp_int<> and not for int. The message I get is

wrong-value.cpp(16): error in
"Mixed_integers<N5boost7mp_math6mp_intISaIvENS0_13mp_int_traitsIjyEEEE>": check
j == 4 failed [-4 != 4]

Regards,

Jeroen.

#define BOOST_TEST_DYN_LINK
#define BOOST_TEST_MODULE Wrong_sign
#include <boost/test/unit_test.hpp>

#include <boost/mp_math/mp_int.hpp>
#include <boost/mpl/list.hpp>

typedef boost::mpl::list< int, boost::mp_math::mp_int<> > test_types;

BOOST_AUTO_TEST_CASE_TEMPLATE( Mixed_integers, Type, test_types )
{
  Type i(-1);
  BOOST_CHECK_EQUAL(i, -1);

  Type j = i + 5;
  BOOST_CHECK_EQUAL(j, 4); // Line 16.
}


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk