1 /*=============================================================================
2 Copyright (c) 2001-2011 Joel de Guzman
3 Copyright (c) 2001-2011 Hartmut Kaiser
4 http://spirit.sourceforge.net/
6 Distributed under the Boost Software License, Version 1.0. (See accompanying
7 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
8 =============================================================================*/
9 #if !defined(SPIRIT_SIGN_MAR_11_2009_0734PM)
10 #define SPIRIT_SIGN_MAR_11_2009_0734PM
16 #include <boost/config/no_tr1/cmath.hpp>
17 #include <boost/version.hpp>
18 #if BOOST_VERSION < 104000
19 #include <boost/spirit/home/support/detail/math/fpclassify.hpp>
20 #include <boost/spirit/home/support/detail/math/signbit.hpp>
22 #include <boost/math/special_functions/fpclassify.hpp>
23 #include <boost/math/special_functions/sign.hpp>
26 namespace boost { namespace spirit { namespace detail
28 #if BOOST_VERSION < 104000
29 // signbit(-NAN) is broken for versions of Boost earlier than 1.40.0
30 // This routine has been taken and adapted from Johan Rade's fp_traits
33 inline bool (signbit)(T x)
35 return (boost::spirit::math::signbit)(x);
39 inline T (changesign)(T x)
41 return (boost::spirit::math::changesign)(x);
45 inline bool (signbit)(T x)
47 return (boost::math::signbit)(x) ? true : false;
50 // This routine has been taken and adapted from Johan Rade's fp_traits
53 inline T (changesign)(T x)
55 #if defined(BOOST_MATH_USE_STD_FPCLASSIFY) && !defined(BOOST_MATH_DISABLE_STD_FPCLASSIFY)
58 typedef typename math::detail::fp_traits<T>::type traits_type;
60 typename traits_type::bits a;
61 traits_type::get_bits(x, a);
62 a ^= traits_type::sign;
63 traits_type::set_bits(x, a);