Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/boost/numeric/interval/detail/c99sub_rounding_control.hpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /* Boost interval/detail/c99sub_rounding_control.hpp file
0002  *
0003  * Copyright 2000 Jens Maurer
0004  * Copyright 2002 Hervé Brönnimann, Guillaume Melquiond, Sylvain Pion
0005  *
0006  * Distributed under the Boost Software License, Version 1.0.
0007  * (See accompanying file LICENSE_1_0.txt or
0008  * copy at http://www.boost.org/LICENSE_1_0.txt)
0009  */
0010 
0011 #ifndef BOOST_NUMERIC_INTERVAL_DETAIL_C99SUB_ROUNDING_CONTROL_HPP
0012 #define BOOST_NUMERIC_INTERVAL_DETAIL_C99SUB_ROUNDING_CONTROL_HPP
0013 
0014 #include <boost/detail/fenv.hpp>      // ISO C 99 rounding mode control
0015 
0016 namespace boost {
0017 namespace numeric {
0018 namespace interval_lib {
0019 namespace detail {
0020 
0021 extern "C" { double rint(double); }
0022 
0023 struct c99_rounding_control
0024 {
0025   typedef int rounding_mode;
0026 
0027   static void set_rounding_mode(rounding_mode mode)  { fesetround(mode); }
0028   static void get_rounding_mode(rounding_mode &mode) { mode = fegetround(); }
0029   static void downward()    { set_rounding_mode(FE_DOWNWARD);   }
0030   static void upward()      { set_rounding_mode(FE_UPWARD);     }
0031   static void to_nearest()  { set_rounding_mode(FE_TONEAREST);  }
0032   static void toward_zero() { set_rounding_mode(FE_TOWARDZERO); }
0033 
0034   template<class T>
0035   static T to_int(const T& r) { return rint(r); }
0036 };
0037 
0038 } // namespace detail
0039 } // namespace interval_lib
0040 } // namespace numeric
0041 } // namespace boost
0042 
0043 #endif // BOOST_NUMERIC_INTERVAL_DETAIL_C99SUB_ROUBDING_CONTROL_HPP