Index: src/examples/io.c
===================================================================
--- src/examples/io.c	(revision 53ba273db2dfa4a4d251429b05f17a6400ed7f1e)
+++ src/examples/io.c	(revision 53ba273db2dfa4a4d251429b05f17a6400ed7f1e)
@@ -0,0 +1,66 @@
+//                               -*- Mode: C -*- 
+// 
+// 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.
+// 
+// io.c -- 
+// 
+// Author           : Peter A. Buhr
+// Created On       : Wed Mar  2 16:56:02 2016
+// Last Modified By : Peter A. Buhr
+// Last Modified On : Wed Apr  6 14:58:27 2016
+// Update Count     : 15
+// 
+
+#include <fstream>
+
+int main() {
+	char c;														// basic types
+	short int si;
+	unsigned short int usi;
+	int i;
+	unsigned int ui;
+	long int li;
+	unsigned long int uli;
+	long long int lli;
+	unsigned long long int ulli;
+	float f;
+	double d;
+	long double ld;
+	float _Complex fc;
+	double _Complex dc;
+	long double _Complex ldc;
+	char s1[10], s2[10];
+
+	ifstream in;												// create / open file
+	open( &in, "input.data", "r" );
+
+	&in | &c													// character
+		| &si | &usi | &i | &ui | &li | &uli | &lli | &ulli		// integral
+		| &f | &d | &ld											// floating point
+		| &fc | &dc | &ldc										// floating-point complex
+		| cstr( s1 ) | cstr( s2, 10 );							// C string, length unchecked and checked
+
+	sout | c | ' ' | endl										// character
+		 | si | usi | i | ui | li | uli | lli | ulli | endl		// integral
+		 | f | d | ld | endl									// floating point
+		 | fc | dc | ldc | endl;								// complex
+	sout | endl;
+	sout | f | "" | d | "" | ld | endl							// floating point without separator
+		 | sepDisable | fc | dc | ldc | sepEnable | endl		// complex without separator
+		 | sepOn | s1 | sepOff | s2 | endl						// local separator removal
+		 | s1 | "" | s2 | endl;									// C string withou separator
+	sout | endl;
+
+	sepSet( sout, ", $" );										// change separator, maximum of 15 characters
+	sout | f | d | ld | endl									// floating point without separator
+		 | fc | dc | ldc | endl									// complex without separator
+		 | s1 | s2 | endl;
+}
+
+// Local Variables: //
+// tab-width: 4 //
+// compile-command: "cfa io.c" //
+// End: //
Index: src/examples/io.data
===================================================================
--- src/examples/io.data	(revision 53ba273db2dfa4a4d251429b05f17a6400ed7f1e)
+++ src/examples/io.data	(revision 53ba273db2dfa4a4d251429b05f17a6400ed7f1e)
@@ -0,0 +1,1 @@
+A 1 2 3 4 5 6 7 8 1.1 1.2 1.3 1.1+2.3 1.1-2.3 1.1-2.3 abc xyz
Index: src/examples/rational.c
===================================================================
--- src/examples/rational.c	(revision 53ba273db2dfa4a4d251429b05f17a6400ed7f1e)
+++ src/examples/rational.c	(revision 53ba273db2dfa4a4d251429b05f17a6400ed7f1e)
@@ -0,0 +1,92 @@
+//                               -*- Mode: C -*- 
+// 
+// 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.c -- 
+// 
+// Author           : Peter A. Buhr
+// Created On       : Mon Mar 28 08:43:12 2016
+// Last Modified By : Peter A. Buhr
+// Last Modified On : Wed Apr  6 18:02:02 2016
+// Update Count     : 19
+// 
+
+#include <limits>
+#include <rational>
+
+int main() {
+	Rational a, b, c;
+	sout | "constructor" | endl;
+	a = rational( 3 );
+	b = rational( 4 );
+	c = rational();
+	sout | a | b | c | endl;
+	a = rational( 4, 8 );
+	b = rational( 5, 7 );
+	sout | a | b | endl;
+	a = rational( -2, -3 );
+	b = rational( 3, -2 );
+	sout | a | b | endl;
+	a = rational( -2, 3 );
+	b = rational( 3, 2 );
+	sout | a | b | endl;
+
+	sout | "logical" | endl;
+	a = rational( -2 );
+	b = rational( -3, 2 );
+	sout | a | b | endl;
+	sout | a == 1 | endl;
+	sout | a != b | endl;
+	sout | a <  b | endl;
+	sout | a <= b | endl;
+	sout | a >  b | endl;
+	sout | a >= b | endl;
+
+	sout | "arithmetic" | endl;
+	sout | a | b | endl;
+	sout | a + b | endl;
+	sout | a - b | endl;
+	sout | a * b | endl;
+	sout | a / b | endl;
+
+	sout | "conversion" | endl;
+	a = rational( 3, 4 );
+	sout | widen( a ) | endl;
+	a = rational( 1, 7 );
+	sout | widen( a ) | endl;
+	a = rational( 355, 113 );
+	sout | widen( a ) | endl;
+	sout | narrow( 0.75, 4 ) | endl;
+	sout | narrow( 0.14285714285714, 16 ) | endl;
+	sout | narrow( 3.14159265358979, 256 ) | endl;
+
+	Rational x, y;
+	x = rational( 1, 2 );
+	y = rational( 2 );
+	sout | x - y | endl;
+	sout | x > y | endl;
+	sout | x | numerator( x, 2 ) | x | endl;
+	sout | y | denominator( y, -2 ) | y | endl;
+
+	Rational z;
+	z = rational( 0, 5 );
+	sout | z | endl;
+
+	sout | x | numerator( x, 0 ) | x | endl;
+
+	x = rational( 1, MAX ) + rational( 1, MAX );
+	sout | x | endl;
+	x = rational( 3, MAX ) + rational( 2, MAX );
+	sout | x | endl;
+
+	sin | &a | &b;
+	sout | a | b | endl;
+} // main
+
+// Local Variables: //
+// tab-width: 4 //
+// compile-command: "cfa rational.c" //
+// End: //
Index: src/examples/rational.cc
===================================================================
--- src/examples/rational.cc	(revision 53ba273db2dfa4a4d251429b05f17a6400ed7f1e)
+++ src/examples/rational.cc	(revision 53ba273db2dfa4a4d251429b05f17a6400ed7f1e)
@@ -0,0 +1,198 @@
+#include "rationalnumber.h"
+
+#include <iostream>
+#include <cstdlib>					// exit
+using namespace std;
+
+static struct {
+    int gcd, con, copy, des, assn, rel, add, sub, mul, div, in, out;
+} stats;						// implicitly initialized to 0
+
+static int gcd( int a, int b ) {
+    for ( ;; ) {
+	int r = a % b;
+      if ( r == 0 ) break;
+	a = b;
+	b = r;
+    } // for
+    stats.gcd += 1;
+    return b;
+} // gcd
+
+void Rationalnumber::statistics() {
+    cerr
+	<< "gcd:"  << stats.gcd  << '\t'
+	<< "con:"  << stats.con  << '\t'
+	<< "copy:" << stats.copy << '\t'
+	<< "des:"  << stats.des  << '\t'
+	<< "assn:" << stats.assn << '\t'
+	<< "rel:"  << stats.rel  << '\t'
+	<< "add:"  << stats.add  << '\t'
+	<< "sub:"  << stats.sub  << '\t'
+	<< "mul:"  << stats.mul  << '\t'
+	<< "div:"  << stats.div  << '\t'
+	<< "in:"   << stats.in   << '\t'
+	<< "out:"  << stats.out
+	<< endl;
+} // Rationalnumber::statistics
+
+bool Rationalnumber::eq( Rationalnumber &r ) {
+    return num * r.denom == denom * r.num;
+} // Rationalnumber::Rationalnumber::eq
+
+bool Rationalnumber::lt( Rationalnumber &r ) {
+    //int temp1 = denom * r.denom, temp2 = num * r.denom, temp3 = denom * r.num;
+    //return temp1 > 0 && temp2 < temp3 || temp1 < 0 && temp2 > temp3;
+    // if denominator is always > 0, only this check is necessary
+    return num * r.denom < denom * r.num;
+} // Rationalnumber::Rationalnumber::lt
+
+void Rationalnumber::common1( int n, int d ) {
+    num = n;
+    denom = d;
+    stats.con += 1;
+} // Rationalnumber::common1
+
+int Rationalnumber::common2( int &n, int &d ) {
+    if ( d == 0 ) {
+	cerr << "Invalid rational number construction: denominator cannot be equal to 0." << endl;
+	exit( EXIT_FAILURE );
+    } // exit
+    if ( d < 0 ) { d = -d; n = -n; }			// move sign to numerator
+    return gcd( abs( n ), d );				// simplify
+} // Rationalnumber::common2
+
+Rationalnumber::Rationalnumber() {
+    common1( 0, 1 );
+} // Rationalnumber::Rationalnumber
+
+Rationalnumber::Rationalnumber( int n ) {
+    common1( n, 1 );
+} // Rationalnumber::Rationalnumber
+
+Rationalnumber::Rationalnumber( int n, int d ) {
+    int temp = common2( n, d );
+    common1( n / temp, d / temp );
+} // Rationalnumber::Rationalnumber
+
+Rationalnumber::Rationalnumber( const Rationalnumber &c ) {
+    num = c.num;
+    denom = c.denom;
+    stats.copy += 1;
+} // Rationalnumber::Rationalnumber
+
+Rationalnumber::~Rationalnumber() {
+    stats.des += 1;
+} // Rationalnumber::~Rationalnumber
+
+Rationalnumber &Rationalnumber::operator=( const Rationalnumber &r ) {
+    num = r.num;
+    denom = r.denom;
+    stats.assn += 1;
+    return *this;
+} // Rationalnumber::operator=
+
+int Rationalnumber::numerator() const {
+    return num;
+} // Rationalnumber::numerator
+
+int Rationalnumber::numerator( int n ) {
+    int prev = num;
+    int temp = gcd( abs( n ), denom );			// simplify
+    num = n / temp;
+    denom = denom / temp;
+    return prev;
+} // Rationalnumber::numerator
+		   
+int Rationalnumber::denominator() const {
+    return denom;
+} // Rationalnumber::denominator
+
+int Rationalnumber::denominator( int d ) {
+    int prev = denom;
+    int temp = common2( num, d );
+    num = num / temp;
+    denom = d / temp;
+    return prev;
+} // Rationalnumber::denominator
+
+bool operator==( Rationalnumber l, Rationalnumber r ) {
+    stats.rel += 1;
+    return l.eq( r );
+} // operator==
+
+bool operator!=( Rationalnumber l, Rationalnumber r ) {
+    stats.rel += 1;
+    return ! ( l.eq( r ) );
+} // operator!=
+
+bool operator<( Rationalnumber l, Rationalnumber r ) {
+    stats.rel += 1;
+    return l.lt( r );
+} // operator<
+
+bool operator<=( Rationalnumber l, Rationalnumber r ) {
+    stats.rel += 1;
+    return l.lt( r ) || l.eq( r );
+} // operator<=
+
+bool operator>( Rationalnumber l, Rationalnumber r ) {
+    stats.rel += 1;
+    return ! ( l.lt( r ) || l.eq( r ) );
+} // operator>
+
+bool operator>=( Rationalnumber l, Rationalnumber r ) {
+    stats.rel += 1;
+    return ! ( l.lt( r ) );
+} // operator>=
+
+Rationalnumber Rationalnumber::operator-() {
+    return Rationalnumber( -num, denom );
+} // Rationalnumber::operator-
+
+Rationalnumber operator+( Rationalnumber l, Rationalnumber r ) {
+    stats.add += 1;
+    if ( l.denom == r.denom ) {				// special case
+	return Rationalnumber( l.num + r.num, l.denom );
+    } else {
+	return Rationalnumber( l.num * r.denom + l.denom * r.num, l.denom * r.denom );
+    } // if
+} // operator+
+
+Rationalnumber operator-( Rationalnumber l, Rationalnumber r ) {
+    stats.sub += 1;
+    if ( l.denom == r.denom ) {				// special case
+	return Rationalnumber( l.num - r.num, l.denom );
+    } else {
+	return Rationalnumber( l.num * r.denom - l.denom * r.num, l.denom * r.denom );
+    } // if
+} // operator-
+
+Rationalnumber operator*( Rationalnumber l, Rationalnumber r ) {
+    stats.mul += 1;
+    return Rationalnumber( l.num * r.num, l.denom * r.denom );
+} // operator*
+
+Rationalnumber operator/( Rationalnumber l, Rationalnumber r ) {
+    stats.div += 1;
+    if ( r.num < 0 ) { r.num = -r.num; r.denom = -r.denom; }
+    return Rationalnumber( l.num * r.denom, l.denom * r.num );
+} // operator/
+
+istream &operator>>( istream &is, Rationalnumber &r ) {
+    stats.in += 1;
+    is >> r.num >> r.denom;
+    int temp = Rationalnumber::common2( r.num, r.denom );
+    r.num /= temp;
+    r.denom /= temp;
+    return is;
+} // operator>>
+
+ostream &operator<<( ostream &os, Rationalnumber r ) {
+    stats.out += 1;
+    return os << r.num << "/" << r.denom;
+} // operator<<
+
+// Local Variables: //
+// compile-command: "make rationalnumber" //
+// End: //
Index: src/examples/read.c
===================================================================
--- src/examples/read.c	(revision 04380914e7d493aa24ecb2e24d89d5752c2133fb)
+++ 	(revision )
@@ -1,60 +1,0 @@
-//                               -*- Mode: C -*- 
-// 
-// 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.
-// 
-// read.c -- 
-// 
-// Author           : Peter A. Buhr
-// Created On       : Wed Mar  2 16:56:02 2016
-// Last Modified By : Peter A. Buhr
-// Last Modified On : Wed Mar  2 16:56:44 2016
-// Update Count     : 2
-// 
-
-#include <fstream>
-
-int main() {
-    char c;
-    short int si;
-    unsigned short int usi;
-    int i;
-    unsigned int ui;
-    long int li;
-    unsigned long int uli;
-    long long int lli;
-    unsigned long long int ulli;
-    float f;
-    double d;
-    long double ld;
-    float _Complex fc;
-    double _Complex dc;
-    long double _Complex ldc;
-    char s1[10], s2[10];
-
-    ifstream in;
-    open( &in, "read.data", "r" );
-
-    &in | &c
-	| &si | &usi | &i | &ui | &li | &uli | &lli | &ulli
-	| &f | &d | &ld
-	| &fc | &dc | &ldc
-	| str( s1 ) | str( s2, 10 );
-
-    sout | c | ' ' | endl
-	 | si | usi | i | ui | li | uli | lli | ulli | endl
-	 | f | d | ld | endl
-	 | f | "" | d | "" | ld | endl;
-
-    sepSet( sout, ", $" );
-    sout | fc | dc | ldc | endl
-	 | sepOn | s1 | sepOff | s2 | endl
-	 | s1 | "" | s2 | endl;
-}
-
-// Local Variables: //
-// tab-width: 4 //
-// compile-command: "cfa read.c" //
-// End: //
Index: src/examples/read.data
===================================================================
--- src/examples/read.data	(revision 04380914e7d493aa24ecb2e24d89d5752c2133fb)
+++ 	(revision )
@@ -1,1 +1,0 @@
-A 1 2 3 4 5 6 7 8 1.1 1.2 1.3 1.1+2.3 1.1-2.3 1.1-2.3 abc xyz
