// // Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo // // The contents of this file are covered under the licence agreement in the // file "LICENCE" distributed with Cforall. // // rational -- // // Author : Peter A. Buhr // Created On : Wed Apr 6 17:56:25 2016 // Last Modified By : Peter A. Buhr // Last Modified On : Wed Apr 6 21:51:42 2016 // Update Count : 8 // #include struct Rational { long int numerator, denominator; // invariant: denominator > 0 }; // Rational extern struct Rational 0; extern struct Rational 1; long int gcd( long int a, long int b ); long int simplify( long int *n, long int *d ); Rational rational(); // constructor Rational rational( long int n ); // constructor Rational rational( long int n, long int d ); // constructor long int numerator( Rational r ); long int numerator( Rational r, long int n ); long int denominator( Rational r, long int d ); int ?==?( Rational l, Rational r ); int ?!=?( Rational l, Rational r ); int ??( Rational l, Rational r ); int ?>=?( Rational l, Rational r ); Rational -?( Rational r ); Rational ?+?( Rational l, Rational r ); Rational ?-?( Rational l, Rational r ); Rational ?*?( Rational l, Rational r ); Rational ?/?( Rational l, Rational r ); double widen( Rational r ); Rational narrow( double f, long int md ); ifstream * ?|?( ifstream *is, Rational *r ); ofstream * ?|?( ofstream *os, Rational r ); // Local Variables: // // mode: c // // tab-width: 4 // // End: //