Re: [Boost-bugs] [Boost C++ Libraries] #10993: frexp with multiprecision cpp_dec_float_50 returns random values with VS 2013

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #10993: frexp with multiprecision cpp_dec_float_50 returns random values with VS 2013
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2015-02-06 09:46:56


#10993: frexp with multiprecision cpp_dec_float_50 returns random values with VS
2013
-------------------------------+-----------------------------------
  Reporter: pbristow | Owner: christopher_kormanyos
      Type: Bugs | Status: new
 Milestone: To Be Determined | Component: multiprecision
   Version: Boost 1.57.0 | Severity: Problem
Resolution: | Keywords: cpp_dec_float_50
-------------------------------+-----------------------------------

Comment (by pbristow):

 I was indeed unwary, and fell straight into the trap :-(

 The original problem was within this templated function:

 {{{

 template <int N, class T = double>
 T nth_2deriv(T x)
 { // return nth root of x using 1st and 2nd derivatives and Halley.

   //typedef double guess_type; // Works OK with this (and may be accurate
 enough anyway).
   typedef T guess_type; // Failed with this with cpp_dec_float_50 only.

   int exponent;
   frexp(static_cast<guess_type>(x), &exponent); // Get exponent of z
 (ignore mantissa).
   T guess = ldexp(static_cast<guess_type>(1.), exponent / N); // Rough
 guess is to divide the exponent by n.
   T min = ldexp(static_cast<guess_type>(1.) / 2, exponent / N); // Minimum
 possible value is half our guess.
   T max = ldexp(static_cast<guess_type>(2.), exponent / N); // Maximum
 possible value is twice our guess.
 ...

 }}}

 Others may appreciate this trap not existing! Thanks.

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/10993#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:17 UTC