~ubuntu-branches/debian/sid/boost1.49/sid

« back to all changes in this revision

Viewing changes to libs/ratio/test/ratio_test.cpp

  • Committer: Package Import Robot
  • Author(s): Steve M. Robbins
  • Date: 2012-02-26 00:31:44 UTC
  • Revision ID: package-import@ubuntu.com-20120226003144-eaytp12cbf6ubpms
Tags: upstream-1.49.0
ImportĀ upstreamĀ versionĀ 1.49.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//  ratio_test.cpp  ----------------------------------------------------------//
 
2
 
 
3
//  Copyright 2008 Howard Hinnant
 
4
//  Copyright 2008 Beman Dawes
 
5
 
 
6
//  Distributed under the Boost Software License, Version 1.0.
 
7
//  See http://www.boost.org/LICENSE_1_0.txt
 
8
 
 
9
#include <boost/ratio/ratio.hpp>
 
10
#include <iostream>
 
11
 
 
12
typedef boost::ratio<5, 3>   five_thirds;       // five_thirds::num == 5, five_thirds::den == 3
 
13
typedef boost::ratio<25, 15> also_five_thirds;  // also_five_thirds::num == 5, also_five_thirds::den == 3
 
14
typedef boost::ratio_divide<five_thirds, also_five_thirds>::type one;  // one::num == 1, one::den == 1
 
15
 
 
16
 
 
17
typedef boost::ratio_multiply<boost::ratio<5>, boost::giga>::type _5giga;  // _5giga::num == 5000000000, _5giga::den == 1
 
18
typedef boost::ratio_multiply<boost::ratio<5>, boost::nano>::type _5nano;  // _5nano::num == 1, _5nano::den == 200000000
 
19
 
 
20
//  Test the case described in library working group issue 948.
 
21
 
 
22
typedef boost::ratio<BOOST_RATIO_INTMAX_C(0x7FFFFFFFFFFFFFFF), BOOST_RATIO_INTMAX_C(0x7FFFFFFFFFFFFFF0)> R1;
 
23
typedef boost::ratio<8, 7> R2;
 
24
typedef boost::ratio_multiply<R1, R2>::type RT;
 
25
 
 
26
 
 
27
 
 
28
int main()
 
29
{
 
30
    typedef boost::ratio<8, BOOST_RATIO_INTMAX_C(0x7FFFFFFFD)> R1;
 
31
    typedef boost::ratio<3, BOOST_RATIO_INTMAX_C(0x7FFFFFFFD)> R2;
 
32
    typedef boost::ratio_subtract<R1, R2>::type RS;
 
33
    std::cout << RS::num << '/' << RS::den << '\n';
 
34
 
 
35
  return 0;
 
36
}