Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_34_1/libs/numeric/interval/test/overflow.cpp @ 29

Last change on this file since 29 was 29, checked in by landauf, 16 years ago

updated boost from 1_33_1 to 1_34_1

File size: 1.1 KB
Line 
1/* Boost test/overflow.cpp
2 * test if extended precision exponent does not disturb interval computation
3 *
4 * Copyright 2002-2003 Guillaume Melquiond
5 *
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)
9 */
10
11#include <boost/numeric/interval.hpp>
12#include <boost/test/minimal.hpp>
13#include "bugs.hpp"
14
15template<class I>
16void test_one(typename I::base_type x, typename I::base_type f) {
17  I y = x;
18  typename I::base_type g = 1 / f;
19  const int nb = 10000;
20  for(int i = 0; i < nb; i++) y *= f;
21  for(int i = 0; i < nb; i++) y *= g;
22  BOOST_CHECK(in(x, y));
23# ifdef __BORLANDC__
24  ::detail::ignore_unused_variable_warning(nb);
25# endif
26}
27
28template<class I>
29void test() {
30  test_one<I>(1., 25.);
31  test_one<I>(1., 0.04);
32  test_one<I>(-1., 25.);
33  test_one<I>(-1., 0.04);
34}
35
36int test_main(int, char *[]) {
37  test<boost::numeric::interval<float> >();
38  test<boost::numeric::interval<double> >();
39  //test<boost::numeric::interval<long double> >();
40# ifdef __BORLANDC__
41  ::detail::ignore_warnings();
42# endif
43  return 0;
44}
Note: See TracBrowser for help on using the repository browser.