Boost logo

Boost :

From: Maarten Keijzer (mak_at_[hidden])
Date: 2000-03-07 08:36:45


Hi all,

I've been checking the interval library a bit as this is precisely what I
needed for some work and the PROFIL/BIAS interval library didn't provide
the proper interface (this apart from the unclarities in making it work on
modern compilers).

As I'm using MSVC I needed to change some stuff in the file interval.hpp
(isnan -> _isnan, include a file msvc_rounding_control.hpp (see below)) in
operators.hpp temporarily hacked a less_than_comparable2<interval<RealType,
Traits>, RealType > class, added std::min and std::max etc.)

Anyway... I got it to work -- more or less.

When testing the sqrt version, I get some errors. What happens basically is
that the NaN values generated by generate_nan() will fall throught the
interval::contain() check. When changing the interval_traits to return
quiet_NaN rather than signaling_NaN everything runs without errors. I'm not
sure which of the two we should return (using MSVC quiet_NaN() is -1.#IND,
while signaling_NaN is -1.#INF). I do not know which of the two is the best
and/or most portable way of implementing Interval::NaN here.

Any ideas?

-Maarten-

The code:

#ifndef BOOST_MSVC_ROUNDING_CONTROL_HPP
#define BOOST_MSVC_ROUNDING_CONTROL_HPP

#ifndef BOOST_INTERVAL_HPP
#error Internal header file: This header must be included by
<boost/interval.hpp> only.
#endif

#ifndef _MSC_VER
#error This header is only intended for MSVC, but might work for Borland as
well
#endif

#include <float.h> // MSVC rounding control

namespace boost {
namespace detail {

class rounding_control
{
public:
   rounding_control() { old_rm = _controlfp(0,0); }
  ~rounding_control() { _controlfp(old_rm, _MCW_RC); }
  void downward() { _controlfp(_RC_DOWN, _MCW_RC); }
  void upward() { _controlfp(_RC_UP, _MCW_RC); }
  void tonearest() { _controlfp(_RC_NEAR, _MCW_RC); }
  void towardzero() { _controlfp( _RC_CHOP, _MCW_RC); }
private:
  unsigned int old_rm;
};

} // namespace detail
} // namespace boost

#endif /* BOOST_MSVC_ROUDING_CONTROL_HPP */

******************************************
Maarten Keijzer

DHI Water & Environment

Agern Allé 11
DK-2970 Hørsholm
Denmark
Phone: +45 45 16 92 00
Direct phone: +45 45 16 93 52
Fax: +45 45 16 92 92
email: mak_at_[hidden]
******************************************

-- Hi, I am a signature virus! Please copy me into your signature file so
that I might spread --


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk