|
Boost : |
Subject: Re: [boost] [lexical_cast][math] can't unconditionally call math::changesign with long double
From: Paul A. Bristow (pbristow_at_[hidden])
Date: 2013-02-24 07:09:48
> -----Original Message-----
> From: Boost [mailto:boost-bounces_at_[hidden]] On Behalf Of Andrey Semashev
> Sent: Sunday, February 24, 2013 9:51 AM
> To: boost_at_[hidden]
> 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_at_[hidden]>:
> > > On 23 February 2013 18:53, Eric Niebler <eniebler_at_[hidden]> 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_at_[hidden]
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk