Index: src/libcfa/rational
===================================================================
--- src/libcfa/rational	(revision 9ebd7781ee3e8287d64d802062ec4ae5620c4c7b)
+++ src/libcfa/rational	(revision 6c6455fa3aff35b9e4792ff0598a10b9ba27d3ea)
@@ -12,6 +12,6 @@
 // Created On       : Wed Apr  6 17:56:25 2016
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Sun May 14 16:49:13 2017
-// Update Count     : 78
+// Last Modified On : Mon May 15 21:30:12 2017
+// Update Count     : 90
 //
 
@@ -128,8 +128,8 @@
 
 // conversion
-// forall ( otype RationalImpl | arithmetic( RationalImpl ) )
-// double widen( Rational(RationalImpl) r );
-// forall ( otype RationalImpl | arithmetic( RationalImpl ) )
-// Rational(RationalImpl) narrow( double f, RationalImpl md );
+forall ( otype RationalImpl | arithmetic( RationalImpl ) | { double convert( RationalImpl ); } )
+double widen( Rational(RationalImpl) r );
+forall ( otype RationalImpl | arithmetic( RationalImpl ) | { double convert( RationalImpl );  RationalImpl convert( double );} )
+Rational(RationalImpl) narrow( double f, RationalImpl md );
 
 // I/O
Index: src/libcfa/rational.c
===================================================================
--- src/libcfa/rational.c	(revision 9ebd7781ee3e8287d64d802062ec4ae5620c4c7b)
+++ src/libcfa/rational.c	(revision 6c6455fa3aff35b9e4792ff0598a10b9ba27d3ea)
@@ -10,6 +10,6 @@
 // Created On       : Wed Apr  6 17:54:28 2016
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Sun May 14 17:25:19 2017
-// Update Count     : 131
+// Last Modified On : Mon May 15 21:29:23 2017
+// Update Count     : 149
 // 
 
@@ -190,37 +190,37 @@
 // conversion
 
-// forall ( otype RationalImpl | arithmetic( RationalImpl ) )
-// double widen( Rational(RationalImpl) r ) {
-// 	return (double)r.numerator / (double)r.denominator;
-// } // widen
-
-// // http://www.ics.uci.edu/~eppstein/numth/frap.c
-// forall ( otype RationalImpl | arithmetic( RationalImpl ) )
-// Rational(RationalImpl) narrow( double f, RationalImpl md ) {
-// 	if ( md <= 1 ) {									// maximum fractional digits too small?
-// 		return (Rational(RationalImpl)){ f, 1};			// truncate fraction
-// 	} // if
-
-// 	// continued fraction coefficients
-// 	RationalImpl m00 = 1, m11 = 1, m01 = 0, m10 = 0;
-// 	RationalImpl ai, t;
-
-// 	// find terms until denom gets too big
-// 	for ( ;; ) {
-// 		ai = (RationalImpl)f;
-// 	  if ( ! (m10 * ai + m11 <= md) ) break;
-// 		t = m00 * ai + m01;
-// 		m01 = m00;
-// 		m00 = t;
-// 		t = m10 * ai + m11;
-// 		m11 = m10;
-// 		m10 = t;
-// 		t = (double)ai;
-// 	  if ( f == t ) break;								// prevent division by zero
-// 	  f = 1 / (f - (double)t);
-// 	  if ( f > (double)0x7FFFFFFF ) break;				// representation failure
-// 	} 
-// 	return (Rational(RationalImpl)){ m00, m10 };
-// } // narrow
+forall ( otype RationalImpl | arithmetic( RationalImpl ) | { double convert( RationalImpl ); } )
+double widen( Rational(RationalImpl) r ) {
+ 	return convert( r.numerator ) / convert( r.denominator );
+} // widen
+
+// http://www.ics.uci.edu/~eppstein/numth/frap.c
+forall ( otype RationalImpl | arithmetic( RationalImpl ) | { double convert( RationalImpl ); RationalImpl convert( double ); } )
+Rational(RationalImpl) narrow( double f, RationalImpl md ) {
+	if ( md <= (RationalImpl){1} ) {					// maximum fractional digits too small?
+		return (Rational(RationalImpl)){ convert( f ), (RationalImpl){1}}; // truncate fraction
+	} // if
+
+	// continued fraction coefficients
+	RationalImpl m00 = {1}, m11 = { 1 }, m01 = { 0 }, m10 = { 0 };
+	RationalImpl ai, t;
+
+	// find terms until denom gets too big
+	for ( ;; ) {
+		ai = convert( f );
+	  if ( ! (m10 * ai + m11 <= md) ) break;
+		t = m00 * ai + m01;
+		m01 = m00;
+		m00 = t;
+		t = m10 * ai + m11;
+		m11 = m10;
+		m10 = t;
+		double temp = convert( ai );
+	  if ( f == temp ) break;							// prevent division by zero
+		f = 1 / (f - temp);
+	  if ( f > (double)0x7FFFFFFF ) break;				// representation failure
+	} // for
+	return (Rational(RationalImpl)){ m00, m10 };
+} // narrow
 
 
Index: src/tests/.expect/rational.txt
===================================================================
--- src/tests/.expect/rational.txt	(revision 9ebd7781ee3e8287d64d802062ec4ae5620c4c7b)
+++ src/tests/.expect/rational.txt	(revision 6c6455fa3aff35b9e4792ff0598a10b9ba27d3ea)
@@ -17,4 +17,11 @@
 3/1
 4/3
+conversion
+0.75
+0.142857142857143
+3.14159292035398
+3/4
+1/7
+355/113
 decompose
 more tests
Index: src/tests/rational.c
===================================================================
--- src/tests/rational.c	(revision 9ebd7781ee3e8287d64d802062ec4ae5620c4c7b)
+++ src/tests/rational.c	(revision 6c6455fa3aff35b9e4792ff0598a10b9ba27d3ea)
@@ -10,6 +10,6 @@
 // Created On       : Mon Mar 28 08:43:12 2016
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Sun May 14 18:10:28 2017
-// Update Count     : 57
+// Last Modified On : Mon May 15 21:32:22 2017
+// Update Count     : 64
 // 
 
@@ -23,4 +23,6 @@
 void ?{}( int * this, zero_t ) { *this = 0; }
 void ?{}( int * this, one_t ) { *this = 1; }
+double convert( int i ) { return (double)i; }
+int convert( double d ) { return (int)d; }
 
 int main() {
@@ -57,14 +59,14 @@
 	sout | a / b | endl;
 
-//	sout | "conversion" | endl;
-//	a = (Rational(int)){ 3, 4 };
-//	sout | widen( a ) | endl;
-//	a = (Rational(int)){ 1, 7 };
-//	sout | widen( a ) | endl;
-//	a = (Rational(int)){ 355, 113 };
-//	sout | widen( a ) | endl;
-//	sout | narrow( 0.75, 4 ) | endl;
-//	sout | narrow( 0.14285714285714, 16 ) | endl;
-//	sout | narrow( 3.14159265358979, 256 ) | endl;
+	sout | "conversion" | endl;
+	a = (Rational(int)){ 3, 4 };
+	sout | widen( a ) | endl;
+	a = (Rational(int)){ 1, 7 };
+	sout | widen( a ) | endl;
+	a = (Rational(int)){ 355, 113 };
+	sout | widen( a ) | endl;
+	sout | narrow( 0.75, 4 ) | endl;
+	sout | narrow( 0.14285714285714, 16 ) | endl;
+	sout | narrow( 3.14159265358979, 256 ) | endl;
 
 	sout | "decompose" | endl;
