Re: [Boost-bugs] [Boost C++ Libraries] #12039: cpp_bin_float convert_to<double>() rounding mistake

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #12039: cpp_bin_float convert_to<double>() rounding mistake
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2016-03-19 22:05:30

#12039: cpp_bin_float convert_to<double>() rounding mistake
  Reporter: Michael Shatz <shatz@…> | Owner: johnmaddock
      Type: Bugs | Status: closed
 Milestone: To Be Determined | Component: multiprecision
   Version: Boost 1.61.0 | Severity: Problem
Resolution: fixed | Keywords:

Comment (by shatz@…):

 May be, I don't know how fetch your patch (my github skills are below
 basic), but it seems to me that instead of fixing bad case you had broken
 good case. Since my stupid test only compares two results of conversion to
 each other, it is happy. But it shouldn't.

 I can't say that I fully understood your cpp_bin_float format (in
 particular, I can't figure out the business with guards) but assuming that
 I didn't misunderstood too badly, I recommend the attached core routine
 for conversion to double.
 In this routine rounding/ties handling is done by compiler/hardware rather
 than by us. Sometimes it does a better job.
 As additional advantage, it's likely several times (or many times for wide
 numbers) faster than your variant.
 Of course, it only works when arg.backend().bits().limbs() has a type
 'uint64_t*' or its equivalent. I didn't figure out if it's a case on all
 supported platforms or only on mine (x64). But even if it's the later, it
 still makes sense to specialize, because I think it's safe to assume that
 x64 platform is by far the most important for your customers.

 Another thing that I didn't figure out is what happens when # of binary
 digits is not an integer multiple of 64. But I would believe, that you
 will have no trouble to handle this case as well. At worst it will take a
 simple mask applied to the first (i.e. least significant) word.

 Best regards,

Ticket URL: <>
Boost C++ Libraries <>
Boost provides free peer-reviewed portable C++ source libraries.

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