Is there a macro to test if std::numerc_limits<>::max_digits10 is supported by a platform?

A proposed (but not reverted) fix for Trac #5758: Boost.Test Floating-point comparison diagnostic output does not support radix 10 if( std::numeric_limits<T>::is_specialized && std::numeric_limits<T>::radix == 10 ) ostr.precision( 2 + std::numeric_limits<T>::max_digits10); // Assume that max_digits10 is provided for all radix 10 as they are quite new, // and anyway Kahan formula will not work for decimal. has caused trouble on platforms that do not yet support std::numeric_limits<T>::max_digits10 We need a macro perhaps BOOST_NO_NUMERIC_LIMITS_ MAX_DIGITS10 that will prevent the compiler seeing this code if max_digits10 is not supported. Do I need to add a default for all compilers # define BOOST_NO_NUMERIC_LIMITS_ MAX_DIGITS10 and then undefine for compilers that DO support #if defined (_MSC_VER >=1600) || (... other compilers that DO support) # undef BOOST_NO_NUMERIC_LIMITS_ MAX_DIGITS10 #endif Can anyone advise compiler versions or library versions that DO support max_digits10? Suggestions? Paul PS maxdigits10 will become more useful generally as the wrong value in float in MSVC 2011 seems to be corrected in Microsoft Visual Studio Ultimate 2012 RC 11.0.50522.1 --- Paul A. Bristow, Prizet Farmhouse, Kendal LA8 8AB UK +44 1539 561830 07714330204 pbristow@hetp.u-net.com

A proposed (but not reverted) fix for
Trac #5758: Boost.Test Floating-point comparison diagnostic output does not support radix 10
if( std::numeric_limits<T>::is_specialized && std::numeric_limits<T>::radix == 10 ) ostr.precision( 2 + std::numeric_limits<T>::max_digits10); // Assume that max_digits10 is provided for all radix 10 as they are quite new, // and anyway Kahan formula will not work for decimal.
has caused trouble on platforms that do not yet support
std::numeric_limits<T>::max_digits10
We need a macro perhaps BOOST_NO_NUMERIC_LIMITS_ MAX_DIGITS10
that will prevent the compiler seeing this code if max_digits10 is not supported.
Try BOOST_NO_NUMERIC_LIMITS_LOWEST as a proxy? John.

-----Original Message----- From: boost-bounces@lists.boost.org [mailto:boost-bounces@lists.boost.org] On Behalf Of John Maddock Sent: Thursday, June 14, 2012 12:14 PM To: boost@lists.boost.org Subject: Re: [boost] Is there a macro to test ifstd::numerc_limits<>::max_digits10 is supported by a platform?
A proposed (but not reverted) fix for
Trac #5758: Boost.Test Floating-point comparison diagnostic output does not support radix 10
if( std::numeric_limits<T>::is_specialized && std::numeric_limits<T>::radix == 10 ) ostr.precision( 2 + std::numeric_limits<T>::max_digits10); // Assume that max_digits10 is provided for all radix 10 as they are quite new, // and anyway Kahan formula will not work for decimal.
has caused trouble on platforms that do not yet support
std::numeric_limits<T>::max_digits10
We need a macro perhaps BOOST_NO_NUMERIC_LIMITS_ MAX_DIGITS10
that will prevent the compiler seeing this code if max_digits10 is not supported.
Try BOOST_NO_NUMERIC_LIMITS_LOWEST as a proxy?
OK, but I'm on holiday for a while so I'll wait until I get back before I create more trouble ;-) Anyone trying multiprecision and wanting this feature can patch their \boost-trunk\boost\test\tools\impl.hpp locally. Thanks Paul --- Paul A. Bristow, Prizet Farmhouse, Kendal LA8 8AB UK +44 1539 561830 07714330204 pbristow@hetp.u-net.com

Hi Paul, On Thursday, 14. June 2012 13:26:20 Paul A. Bristow wrote:
-----Original Message----- From: boost-bounces@lists.boost.org [mailto:boost-bounces@lists.boost.org] On Behalf Of John Maddock
Try BOOST_NO_NUMERIC_LIMITS_LOWEST as a proxy?
OK, but I'm on holiday for a while so I'll wait until I get back before I create more trouble ;-)
Anyone trying multiprecision and wanting this feature can patch their \boost-trunk\boost\test\tools\impl.hpp locally.
I've tested BOOST_NO_NUMERIC_LIMITS_LOWEST with gcc-4.6.3 on Linux and this seems to work. Patch attached. I'd like to commit it and check the test results for breaks. Or is a special macro needed here? Yours, Jürgen -- * Dipl.-Math. Jürgen Hunold ! * voice: ++49 4257 300 ! Fährstraße 1 * fax : ++49 4257 300 ! 31609 Balge/Sebbenhausen * jhunold@gmx.eu ! Germany

-----Original Message----- From: boost-bounces@lists.boost.org [mailto:boost-bounces@lists.boost.org] On Behalf Of Jürgen Hunold Sent: Saturday, June 16, 2012 11:49 AM To: boost@lists.boost.org Subject: Re: [boost] Is there a macro to test ifstd::numerc_limits<>::max_digits10 is supported by a platform?
Hi Paul,
On Thursday, 14. June 2012 13:26:20 Paul A. Bristow wrote:
-----Original Message----- From: boost-bounces@lists.boost.org [mailto:boost-bounces@lists.boost.org] On Behalf Of John Maddock
Try BOOST_NO_NUMERIC_LIMITS_LOWEST as a proxy?
OK, but I'm on holiday for a while so I'll wait until I get back before I create more trouble ;-)
Anyone trying multiprecision and wanting this feature can patch their \boost-trunk\boost\test\tools\impl.hpp locally.
I've tested BOOST_NO_NUMERIC_LIMITS_LOWEST with gcc-4.6.3 on Linux and this seems to work.
Patch attached.
Thanks - looks good, but I think it might be wise to test how the macro works on a specific test not actually using Boost.Test before causing a nuisance - as I have discovered to several peoples cost :-( The trouble is that Boost.Test is used by all platforms. So it will be disruptive to just patch like this and hope for the best.
I'd like to commit it and check the test results for breaks.
Or is a special macro needed here?
Well perhaps but hopefully not - only a check on all platforms in the testing regime will make sure. I'll check this out, perhaps using a temporary program attached to Boost.Math testing schedule and then see what platforms work. There may still be obscure platforms that are not routinely tested that don't work? Paul --- Paul A. Bristow, Prizet Farmhouse, Kendal LA8 8AB UK +44 1539 561830 07714330204 pbristow@hetp.u-net.com
participants (3)
-
John Maddock
-
Jürgen Hunold
-
Paul A. Bristow