1
0
This repository has been archived on 2025-03-06. You can view files and clone it, but cannot push or open issues or pull requests.
Jip J. Dekker 981be2067e Squashed 'software/gecode_on_replay/' content from commit 8051d92b9
git-subtree-dir: software/gecode_on_replay
git-subtree-split: 8051d92b9c89e49cccfbd1c201371580d7703ab4
2021-06-16 14:04:29 +10:00

44 lines
1.4 KiB
C++

/* Boost interval/detail/c99sub_rounding_control.hpp file
*
* Copyright 2000 Jens Maurer
* Copyright 2002 Hervé Brönnimann, Guillaume Melquiond, Sylvain Pion
*
* 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)
*/
#ifndef GECODE_BOOST_NUMERIC_INTERVAL_DETAIL_C99SUB_ROUNDING_CONTROL_HPP
#define GECODE_BOOST_NUMERIC_INTERVAL_DETAIL_C99SUB_ROUNDING_CONTROL_HPP
#include <fenv.h> // ISO C 99 rounding mode control
namespace gecode_boost {
namespace numeric {
namespace interval_lib {
namespace detail {
extern "C" { double rint(double); }
struct c99_rounding_control
{
typedef int rounding_mode;
static void set_rounding_mode(rounding_mode mode) { fesetround(mode); }
static void get_rounding_mode(rounding_mode &mode) { mode = fegetround(); }
static void downward() { set_rounding_mode(FE_DOWNWARD); }
static void upward() { set_rounding_mode(FE_UPWARD); }
static void to_nearest() { set_rounding_mode(FE_TONEAREST); }
static void toward_zero() { set_rounding_mode(FE_TOWARDZERO); }
template<class T>
static T to_int(const T& r) { return rint(r); }
};
} // namespace detail
} // namespace interval_lib
} // namespace numeric
} // namespace gecode_boost
#endif // GECODE_BOOST_NUMERIC_INTERVAL_DETAIL_C99SUB_ROUBDING_CONTROL_HPP