[Boost-bugs] [Boost C++ Libraries] #5758: Boost.Test Floating-point comparison diagnostic output does not support radix 10

Subject: [Boost-bugs] [Boost C++ Libraries] #5758: Boost.Test Floating-point comparison diagnostic output does not support radix 10
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2011-08-06 11:06:30


#5758: Boost.Test Floating-point comparison diagnostic output does not support
radix 10
-------------------------------------------------------+--------------------
 Reporter: pbristow | Owner: rogeeff
     Type: Support Requests | Status: new
Milestone: Boost 1.48.0 | Component: test
  Version: Boost Development Trunk | Severity: Problem
 Keywords: floating point radix 10 decimal precision |
-------------------------------------------------------+--------------------
 Boost.Test Floating-point comparison diagnostic output does not support
 radix 10.

 This emerged as a problem writing tests for Christopher Kormanyos proposed
 e_float extended precision float library which uses radix 10.

 Tests that fail do not provide sufficient decimal digits to reveal why the
 test fails.

 Numeric_limits is properly specialized for e_float, so max_digits10 is
 valid (and this is also true for a recent fixed decimal library.

 So I suggest that in test_tools.hpp function set_precision

 After dealing with the radix = 2 case,

 (and noting that although we would like to rely on max_digits10, older
 compilers/libraries do not provide it, and the recent MS VC10 wrongly
 implements float max_digits10 as 8 instead of 9, it is safer to continue
 to use the original Kahan formula)>

       // Ideally should use max_digits10 if available, and correct! But
 this always works.
         if( std::numeric_limits<T>::is_specialized &&
 std::numeric_limits<T>::radix

 Add new code to deal with the radix=10 case (but in this case '''we can
 rely on max_digits10''')

         // If radix = 10, is recent code so assume max_digits10 should be
 correct.
         // For example, e_float and a fixed decimal package(s) both
 comply.

         if( std::numeric_limits<T>::is_specialized &&
 std::numeric_limits<T>::radix == 10 )
             ostr.precision( std::numeric_limits<T>::max_digits10 );

 (Might also be worth a comment that for other cases, precision will remain
 at the default value, whatever that is).

 This has been tested and works as expected for e_float.

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