Re: [Boost-bugs] [Boost C++ Libraries] #8133: multiprecision, failed gcd tests (test_cpp_int.cpp)

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #8133: multiprecision, failed gcd tests (test_cpp_int.cpp)
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2013-02-21 14:46:49


#8133: multiprecision, failed gcd tests (test_cpp_int.cpp)
---------------------------------------------------+------------------------
  Reporter: Stepan Podoskin <stepik-777@…> | Owner: johnmaddock
      Type: Bugs | Status: new
 Milestone: To Be Determined | Component: multiprecision
   Version: Boost 1.53.0 | Severity: Problem
Resolution: | Keywords:
---------------------------------------------------+------------------------

Comment (by Stepan Podoskin <stepik-777@…>):

 Yes, you are right, it should be (val == 0) ? 1 : val;

 This line is there because tests will fail with division by zero
 otherwise.

 I'm testing it on 32-bit Windows with GCC 4.7.2 and MSVC 2010. I'm using
 boost 1.53.0, not the latest trunk. Following program outputs 1 1 1 3 when
 compiled with GCC and 3 3 1 3 and when complied with MSVC.
 {{{

 #include <iostream>
 #include <boost/multiprecision/cpp_int.hpp>
 using boost::multiprecision::cpp_int;
 using boost::multiprecision::gcd;

 int main()
 {
     cpp_int
 a("0xffffffee00000095fffffd0000000a8fffffe4e10000348bffffb1a100005ae3ffffade700003955ffffe19900000bd2fffffcdb00000076fffffffffffffffd");

     // correct gcd is 1
     std::cout << gcd(a, 4294967295) << '\n';
     std::cout << gcd(4294967295, a) << '\n';
     std::cout << gcd(a, cpp_int("4294967295")) << '\n';
     std::cout << gcd(cpp_int("4294967295"), a) << '\n';
     return 0;
 }

 }}}

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/8133#comment:2>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:12 UTC