]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/numeric/interval/examples/rational.cpp
1 /* Boost example/rational.cpp
2 * example program of how to use interval< rational<> >
4 * Copyright 2002-2003 Guillaume Melquiond, Sylvain Pion
6 * Distributed under the Boost Software License, Version 1.0.
7 * (See accompanying file LICENSE_1_0.txt or
8 * copy at http://www.boost.org/LICENSE_1_0.txt)
11 // it would have been enough to only include:
12 // <boost/numeric/interval.hpp>
13 // but it's a bit overkill to include processor intrinsics
14 // and transcendental functions, so we do it by ourselves
16 #include <boost/numeric/interval/interval.hpp> // base class
17 #include <boost/numeric/interval/rounded_arith.hpp> // default arithmetic rounding policy
18 #include <boost/numeric/interval/checking.hpp> // default checking policy
19 #include <boost/numeric/interval/arith.hpp> // += *= -= etc
20 #include <boost/numeric/interval/policies.hpp> // default policy
22 #include <boost/rational.hpp>
25 typedef boost::rational
<int> Rat
;
26 typedef boost::numeric::interval
<Rat
> Interval
;
28 std::ostream
& operator<<(std::ostream
& os
, const Interval
& r
) {
29 os
<< "[" << r
.lower() << "," << r
.upper() << "]";
41 std::cout
<< z
<< std::endl
;
42 std::cout
<< a
<< std::endl
;