Opened 10 years ago

Closed 10 years ago

#8065 closed Bugs (fixed)

Multiprecision rounding issue

Reported by: Matthias Wagner <MWagner@…> Owned by: John Maddock
Milestone: To Be Determined Component: multiprecision
Version: Boost 1.53.0 Severity: Problem
Keywords: multiprecision, round Cc: e_float@…

Description

When running the attached program, rounding issues occur. The program shifts a boost::multiprecision::cpp_dec_float<N>(1) by N digits left, then calls the round method and shifts back to the right. The round method fails to truncate the 0.5 it adds for some N. The issue becomes worse if you shift even further to the left or use a higher initial value. The problematic code seems to be in cpp_dec_float<>::extract_integer_part, which decides that no truncation is required, although the guard digits are not zero. For me, removing the whole else if (exp >=...) {} clause seemed to fix it.

Attachments (1)

MPRoundingBug.cpp (955 bytes ) - added by Matthias Wagner <MWagner@…> 10 years ago.

Download all attachments as: .zip

Change History (4)

by Matthias Wagner <MWagner@…>, 10 years ago

Attachment: MPRoundingBug.cpp added

comment:1 by John Maddock, 10 years ago

Cc: e_float@… added; John Maddock removed

Chris, can you take a look at this one?

Many thanks, John.

comment:2 by christopher_kormanyos, 10 years ago

(In [82920]) Refs #8065

comment:3 by John Maddock, 10 years ago

Resolution: fixed
Status: newclosed

Closing as this is fixed now.

Note: See TracTickets for help on using tickets.