1 | // |
---|
2 | // Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo |
---|
3 | // |
---|
4 | // The contents of this file are covered under the licence agreement in the |
---|
5 | // file "LICENCE" distributed with Cforall. |
---|
6 | // |
---|
7 | // rational -- |
---|
8 | // |
---|
9 | // Author : Peter A. Buhr |
---|
10 | // Created On : Wed Apr 6 17:56:25 2016 |
---|
11 | // Last Modified By : Peter A. Buhr |
---|
12 | // Last Modified On : Wed Apr 6 21:51:42 2016 |
---|
13 | // Update Count : 8 |
---|
14 | // |
---|
15 | |
---|
16 | #include <fstream> |
---|
17 | |
---|
18 | struct Rational { |
---|
19 | long int numerator, denominator; // invariant: denominator > 0 |
---|
20 | }; // Rational |
---|
21 | |
---|
22 | extern struct Rational 0; |
---|
23 | extern struct Rational 1; |
---|
24 | |
---|
25 | long int gcd( long int a, long int b ); |
---|
26 | long int simplify( long int *n, long int *d ); |
---|
27 | Rational rational(); // constructor |
---|
28 | Rational rational( long int n ); // constructor |
---|
29 | Rational rational( long int n, long int d ); // constructor |
---|
30 | long int numerator( Rational r ); |
---|
31 | long int numerator( Rational r, long int n ); |
---|
32 | long int denominator( Rational r, long int d ); |
---|
33 | int ?==?( Rational l, Rational r ); |
---|
34 | int ?!=?( Rational l, Rational r ); |
---|
35 | int ?<?( Rational l, Rational r ); |
---|
36 | int ?<=?( Rational l, Rational r ); |
---|
37 | int ?>?( Rational l, Rational r ); |
---|
38 | int ?>=?( Rational l, Rational r ); |
---|
39 | Rational -?( Rational r ); |
---|
40 | Rational ?+?( Rational l, Rational r ); |
---|
41 | Rational ?-?( Rational l, Rational r ); |
---|
42 | Rational ?*?( Rational l, Rational r ); |
---|
43 | Rational ?/?( Rational l, Rational r ); |
---|
44 | double widen( Rational r ); |
---|
45 | Rational narrow( double f, long int md ); |
---|
46 | ifstream * ?|?( ifstream *is, Rational *r ); |
---|
47 | ofstream * ?|?( ofstream *os, Rational r ); |
---|
48 | |
---|
49 | // Local Variables: // |
---|
50 | // mode: c // |
---|
51 | // tab-width: 4 // |
---|
52 | // End: // |
---|