Modify

Ticket #8160 (closed Bugs: fixed)

Opened 14 months ago

Last modified 14 months ago

multiprecision: Number is not assigned after dividing zero by something.

Reported by: Stepan Podoskin <stepik-777@…> Owned by: johnmaddock
Milestone: To Be Determined Component: multiprecision
Version: Boost 1.53.0 Severity: Problem
Keywords: Cc:

Description

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

int main()
{
    cpp_int a = 1;
    a = 0/cpp_int("1");
    std::cout << "a = " << a << "\n"; // a = 1
    return 0;
}

divide.hpp: line 341 says All the limbs in x are zero, so is the result:

However, result is not assigned to zero.

Attachments

fix.patch Download (494 bytes) - added by Stepan Podoskin <stepik-777@…> 14 months ago.
patch "boost/multiprecision"

Change History

Changed 14 months ago by Stepan Podoskin <stepik-777@…>

patch "boost/multiprecision"

comment:1 Changed 14 months ago by Stepan Podoskin <stepik-777@…>

  • Summary changed from multiprecision: Number is not assinned after dividing zero by something. to multiprecision: Number is not assigned after dividing zero by something.

comment:2 Changed 14 months ago by johnmaddock

Confirmed.

comment:3 Changed 14 months ago by johnmaddock

  • Status changed from new to closed
  • Resolution set to fixed

(In [83128]) Fix bug in division of zero. Document and add tests. Fixes #8160.

comment:4 Changed 14 months ago by Stepan Podoskin <stepik-777@…>

I just want to note that comparison with zero here isn't necessary.

There is:

   if((r_order == 0) && (*pr == 0))

And few lines below:

   if((r_order == 0) && (*pr < y))

There is no reason to treat zero as some special value, it will be handled by second if, so lines 339-345 can be simply removed.

comment:5 Changed 14 months ago by johnmaddock

Um.. clearly the bug I have at present has eaten my brains away :-(

Will fix shortly, thanks for your patience!

comment:6 Changed 14 months ago by johnmaddock

(In [83153]) Better fix for #8160. Refs #8160.

View

Add a comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
The resolution will be deleted. Next status will be 'reopened'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.