[lexical_cast][math] can't unconditionally call math::changesign with long double

lexical_cast is using math::changesign with long double regardless of whether BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS is defined or not. This is causing Boost.Test build problems (see here http://tinyurl.com/af5453h). I'm pretty sure this is a bug in lexical_cast, so I've opened a ticket: https://svn.boost.org/trac/boost/ticket/8162 I've assigned it to the last person to touch lexical_cast.hpp. Apologies if that's not right. There is no entry for lexical_cast in libs/maintainers.txt. -- Eric Niebler Boost.org http://www.boost.org

On 23 February 2013 18:53, Eric Niebler <eniebler@boost.org> wrote:
lexical_cast is using math::changesign with long double regardless of whether BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS is defined or not. This is causing Boost.Test build problems (see here http://tinyurl.com/af5453h ).
I'm pretty sure this is a bug in lexical_cast, so I've opened a ticket: https://svn.boost.org/trac/boost/ticket/8162
I've assigned it to the last person to touch lexical_cast.hpp. Apologies if that's not right. There is no entry for lexical_cast in libs/maintainers.txt.
You've assigned it to the right person, Antony has become the new maintainer of lexical_cast as per http://lists.boost.org/Archives/boost/2011/05/181523.php. This is also reflected in https://svn.boost.org/trac/boost/report/15 and should probably be added to libs/maintainers.txt.
-- Eric Niebler Boost.org http://www.boost.org
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Jeroen

2013/2/24 Jeroen Habraken <vexocide@gmail.com>:
On 23 February 2013 18:53, Eric Niebler <eniebler@boost.org> wrote:
lexical_cast is using math::changesign with long double regardless of whether BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS is defined or not. This is causing Boost.Test build problems (see here http://tinyurl.com/af5453h ).
I'm pretty sure this is a bug in lexical_cast, so I've opened a ticket: https://svn.boost.org/trac/boost/ticket/8162
So, portable way of changing sign is just to multiply on -1 ? And math::isnan I shall change to value != value ? And math::isinf to something like value >= numeric_limits<>::max? But why don't we do that in Boost.Math?
I've assigned it to the last person to touch lexical_cast.hpp. Apologies if that's not right. There is no entry for lexical_cast in libs/maintainers.txt.
You've assigned it to the right person, Antony has become the new maintainer of lexical_cast as per http://lists.boost.org/Archives/boost/2011/05/181523.php. This is also reflected in https://svn.boost.org/trac/boost/report/15 and should probably be added to libs/maintainers.txt.
I'll commit changes to libs/maintainers.txt today. -- Best regards, Antony Polukhin

lexical_cast is using math::changesign with long double regardless of whether BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS is defined or not. This is causing Boost.Test build problems (see here http://tinyurl.com/af5453h ).
I'm pretty sure this is a bug in lexical_cast, so I've opened a ticket: https://svn.boost.org/trac/boost/ticket/8162
So, portable way of changing sign is just to multiply on -1 ?
Doesn't work for NaN's if you care about that (probably not in this case?)
And math::isnan I shall change to value != value ?
That doesn't always work, actually it quite often doesn't work, especially in release mode.
And math::isinf to something like value >= numeric_limits<>::max?
Make that fabs(value) > numeric_limits<>::max and it should work - unless of course the system has no (reliable) long double math functions in which case fabs(double) may be called rather than a true fabs(long double), and you may get spurious overflow (finite long double treated as non-finite double). Fun isn't it? :-( John.

On Sunday 24 February 2013 09:51:27 Antony Polukhin wrote:
2013/2/24 Jeroen Habraken <vexocide@gmail.com>:
On 23 February 2013 18:53, Eric Niebler <eniebler@boost.org> wrote:
lexical_cast is using math::changesign with long double regardless of whether BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS is defined or not. This is causing Boost.Test build problems (see here http://tinyurl.com/af5453h ).
I'm pretty sure this is a bug in lexical_cast, so I've opened a ticket: https://svn.boost.org/trac/boost/ticket/8162
So, portable way of changing sign is just to multiply on -1 ?
You could toggle the most significant bit, if FP numbers have IEEE 754 format (which should be common nowdays). Unlike multiplication, this would keep the precision and is faster.

-----Original Message----- From: Boost [mailto:boost-bounces@lists.boost.org] On Behalf Of Andrey Semashev Sent: Sunday, February 24, 2013 9:51 AM To: boost@lists.boost.org Subject: Re: [boost] [lexical_cast][math] can't unconditionally call math::changesign with long double
On Sunday 24 February 2013 09:51:27 Antony Polukhin wrote:
2013/2/24 Jeroen Habraken <vexocide@gmail.com>:
On 23 February 2013 18:53, Eric Niebler <eniebler@boost.org> wrote:
lexical_cast is using math::changesign with long double regardless of whether BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS is defined or not. This is causing Boost.Test build problems (see here http://tinyurl.com/af5453h ).
I'm pretty sure this is a bug in lexical_cast, so I've opened a ticket: https://svn.boost.org/trac/boost/ticket/8162
So, portable way of changing sign is just to multiply on -1 ?
You could toggle the most significant bit, if FP numbers have IEEE 754 format (which should be common nowdays). Unlike multiplication, this would keep the precision and is faster.
I think this is what changesign does? So it works for NaN where all comparisons and tests fail. If changesign is implemented, it should not rely on IEEE 754 format. As John says, portability is all good fun ;-) Paul --- Paul A. Bristow, Prizet Farmhouse, Kendal LA8 8AB UK +44 1539 561830 07714330204 pbristow@hetp.u-net.com

2013/2/24 Paul A. Bristow <pbristow@hetp.u-net.com>:
On Sunday 24 February 2013 09:51:27 Antony Polukhin wrote:
2013/2/24 Jeroen Habraken <vexocide@gmail.com>:
On 23 February 2013 18:53, Eric Niebler <eniebler@boost.org> wrote:
lexical_cast is using math::changesign with long double regardless of whether BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS is defined or not. This is causing Boost.Test build problems (see here http://tinyurl.com/af5453h ).
I'm pretty sure this is a bug in lexical_cast, so I've opened a ticket: https://svn.boost.org/trac/boost/ticket/8162
So, portable way of changing sign is just to multiply on -1 ?
You could toggle the most significant bit, if FP numbers have IEEE 754 format (which should be common nowdays). Unlike multiplication, this would keep the precision and is faster.
I think this is what changesign does? So it works for NaN where all comparisons and tests fail. If changesign is implemented, it should not rely on IEEE 754 format.
As John says, portability is all good fun ;-)
OK, I'll just disable optimized conversions to doubles when there is no support for long doubles in Boost.Math. This may take a few weeks. -- Best regards, Antony Polukhin
participants (6)
-
Andrey Semashev
-
Antony Polukhin
-
Eric Niebler
-
Jeroen Habraken
-
John Maddock
-
Paul A. Bristow