3 #ifndef BOOST_SPIRIT_MATH_SIGNBIT_HPP
4 #define BOOST_SPIRIT_MATH_SIGNBIT_HPP
6 // Copyright (c) 2006 Johan Rade
8 // Distributed under the Boost Software License, Version 1.0.
9 // (See accompanying file LICENSE_1_0.txt
10 // or copy at http://www.boost.org/LICENSE_1_0.txt)
16 #include <boost/spirit/home/support/detail/math/detail/fp_traits.hpp>
22 //------------------------------------------------------------------------------
24 template<class T> bool (signbit)(T x)
26 typedef BOOST_DEDUCED_TYPENAME detail::fp_traits<T>::type traits;
29 BOOST_DEDUCED_TYPENAME traits::bits a;
30 traits::get_bits(x,a);
35 //------------------------------------------------------------------------------
39 template<class T> T copysign_impl(T x, T y)
41 typedef BOOST_DEDUCED_TYPENAME fp_traits<T>::type traits;
44 BOOST_DEDUCED_TYPENAME traits::bits a;
45 traits::get_bits(x,a);
48 BOOST_DEDUCED_TYPENAME traits::bits b;
49 traits::get_bits(y,b);
52 traits::set_bits(x,a|b);
57 inline float (copysign)(float x, float y) // magnitude of x and sign of y
59 return detail::copysign_impl(x,y);
62 inline double (copysign)(double x, double y)
64 return detail::copysign_impl(x,y);
67 inline long double (copysign)(long double x, long double y)
69 return detail::copysign_impl(x,y);
72 //------------------------------------------------------------------------------
74 template<class T> T (changesign)(T x)
76 typedef BOOST_DEDUCED_TYPENAME detail::fp_traits<T>::type traits;
79 BOOST_DEDUCED_TYPENAME traits::bits a;
80 traits::get_bits(x,a);
82 traits::set_bits(x,a);
86 //------------------------------------------------------------------------------