⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 signbit.hpp

📁 Boost provides free peer-reviewed portable C++ source libraries. We emphasize libraries that work
💻 HPP
字号:
// signbit.hpp#ifndef BOOST_MATH_SIGNBIT_HPP#define BOOST_MATH_SIGNBIT_HPP// Copyright (c) 2006 Johan Rade// Distributed under the Boost Software License, Version 1.0.// (See accompanying file LICENSE_1_0.txt// or copy at http://www.boost.org/LICENSE_1_0.txt)#include "detail/fp_traits.hpp"namespace boost {namespace math {//------------------------------------------------------------------------------template<class T> bool (signbit)(T x){    typedef BOOST_DEDUCED_TYPENAME detail::fp_traits<T>::type traits;    traits::init();    BOOST_DEDUCED_TYPENAME traits::bits a;    traits::get_bits(x,a);    a &= traits::sign;    return a != 0;}//------------------------------------------------------------------------------namespace detail {    template<class T> T copysign_impl(T x, T y)    {        typedef BOOST_DEDUCED_TYPENAME fp_traits<T>::type traits;        traits::init();        BOOST_DEDUCED_TYPENAME traits::bits a;        traits::get_bits(x,a);        a &= ~traits::sign;        BOOST_DEDUCED_TYPENAME traits::bits b;        traits::get_bits(y,b);        b &= traits::sign;        traits::set_bits(x,a|b);        return x;    }}inline float (copysign)(float x, float y)      // magnitude of x and sign of y{    return detail::copysign_impl(x,y);}inline double (copysign)(double x, double y){    return detail::copysign_impl(x,y);}inline long double (copysign)(long double x, long double y){    return detail::copysign_impl(x,y);}//------------------------------------------------------------------------------template<class T> T (changesign)(T x){    typedef BOOST_DEDUCED_TYPENAME detail::fp_traits<T>::type traits;    traits::init();    BOOST_DEDUCED_TYPENAME traits::bits a;    traits::get_bits(x,a);    a ^= traits::sign;    traits::set_bits(x,a);    return x;}//------------------------------------------------------------------------------}   // namespace math}   // namespace boost#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -