Modify

Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#8160 closed Bugs (fixed)

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

Reported by: Stepan Podoskin <stepik-777@…> Owned by: John Maddock
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 (1)

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

Download all attachments as: .zip

Change History (7)

Changed 5 years ago by Stepan Podoskin <stepik-777@…>

Attachment: fix.patch added

patch "boost/multiprecision"

comment:1 Changed 5 years ago by Stepan Podoskin <stepik-777@…>

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

comment:2 Changed 5 years ago by John Maddock

Confirmed.

comment:3 Changed 5 years ago by John Maddock

Resolution: fixed
Status: newclosed

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

comment:4 Changed 5 years 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 5 years ago by John Maddock

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

Will fix shortly, thanks for your patience!

comment:6 Changed 5 years ago by John Maddock

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

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain John Maddock.
The resolution will be deleted.

Add Comment


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

 
Note: See TracTickets for help on using tickets.