Index: libpolys/coeffs/coeffs.h
===================================================================
--- libpolys/coeffs/coeffs.h	(revision 0e7635908ba5356fa51c0a4755ec1eae88a9b328)
+++ libpolys/coeffs/coeffs.h	(revision e8c8d577a2c68f346822b68f71832651960d1ba0)
@@ -159,4 +159,6 @@
    number  (*cfGcd)(number a, number b, const coeffs r);
    number  (*cfLcm)(number a, number b, const coeffs r);
+   number  (*cfChineseRemainder)(number *a, number *b, int rl, const coeffs r);
+   number  (*cfFarey)(number a, number b, const coeffs r);
    void    (*cfDelete)(number * a, const coeffs r);
    nMapFunc (*cfSetMap)(const coeffs src, const coeffs dst);
@@ -557,4 +559,18 @@
 }
 
+static inline number n_ChineseRemainder(number *a, number *b, int rl, const coeffs r)
+{
+  assume(r != NULL);
+  assume(getCoeffType(r)==n_Q);
+  return r->cfChineseRemainder(a,b,rl,r);
+}
+
+static inline number n_farey(number a, number b, const coeffs r)
+{
+  assume(r != NULL);
+  assume(getCoeffType(r)==n_Q);
+  return r->cfFarey(a,b,r);
+}
+
 /// returns TRUE, if r is not a field and r has non-trivial units
 static inline BOOLEAN nCoeff_has_Units(const coeffs r)
Index: libpolys/coeffs/longrat.cc
===================================================================
--- libpolys/coeffs/longrat.cc	(revision 0e7635908ba5356fa51c0a4755ec1eae88a9b328)
+++ libpolys/coeffs/longrat.cc	(revision e8c8d577a2c68f346822b68f71832651960d1ba0)
@@ -2546,4 +2546,36 @@
 }
 
+number   nlChineseRemainder(number *x, number *q,int rl, const coeffs C)
+// elemenst in the array are x[0..(rl-1)], q[0..(rl-1)]
+{
+#ifdef HAVE_FACTORY
+  setCharacteristic( 0 ); // only in char 0
+  CFArray X(rl), Q(rl);
+  int i;
+  for(i=rl-1;i>=0;i--)
+  {
+    X[i]=C->convSingNFactoryN(x[i],FALSE,C); // may be larger MAX_INT
+    Q[i]=C->convSingNFactoryN(q[i],FALSE,C); // may be larger MAX_INT
+  }
+  CanonicalForm xnew,qnew;
+  chineseRemainder(X,Q,xnew,qnew);
+  number n=C->convFactoryNSingN(xnew,C);
+  number p=C->convFactoryNSingN(qnew,C);
+  number p2=nlIntDiv(p,nlInit(2, C),C);
+  if (nlGreater(n,p2,C))
+  {
+     number n2=nlSub(n,p,C);
+     nlDelete(&n,C);
+     n=n2;
+  }
+  nlDelete(&p,C);
+  nlDelete(&p2,C);
+  return n;
+#else
+  WerrorS("not implemented");
+  return nlInit(0);
+#endif
+}
+
 BOOLEAN nlInitChar(coeffs r, void*)
 {
@@ -2566,4 +2598,6 @@
   r->cfSize  = nlSize;
   r->cfInt  = nlInt;
+  r->cfChineseRemainder=nlChineseRemainder;
+  r->cfFarey=nlFarey;
   #ifdef HAVE_RINGS
   //r->cfDivComp = NULL; // only for ring stuff
Index: libpolys/coeffs/longrat.h
===================================================================
--- libpolys/coeffs/longrat.h	(revision 0e7635908ba5356fa51c0a4755ec1eae88a9b328)
+++ libpolys/coeffs/longrat.h	(revision e8c8d577a2c68f346822b68f71832651960d1ba0)
@@ -88,4 +88,6 @@
 number   nlGetNumerator(number &n, const coeffs r);
 void     nlCoeffWrite(const coeffs r);
+number   nlChineseRemainder(number *x, number *q,int rl, const coeffs C);
+number   nlFarey(number nN, number nP, const coeffs CF);
 #ifdef LDEBUG
 BOOLEAN  nlDBTest(number a, const char *f, const int l);
@@ -109,6 +111,4 @@
 LINLINE void nlInpMult(number &a, number b, const coeffs r);
 
-number nlFarey(number nP, number nN);
-
 #ifdef LDEBUG
 #define nlTest(a, r) nlDBTest(a,__FILE__,__LINE__, r)
Index: libpolys/coeffs/numbers.cc
===================================================================
--- libpolys/coeffs/numbers.cc	(revision 0e7635908ba5356fa51c0a4755ec1eae88a9b328)
+++ libpolys/coeffs/numbers.cc	(revision e8c8d577a2c68f346822b68f71832651960d1ba0)
@@ -117,4 +117,5 @@
 number nd_Copy(number a, const coeffs r) { return n_Copy(a, r); }
 
+number ndChineseRemainder(number *,number *,int,const coeffs r){ return n_Init(0,r); }
 #ifdef HAVE_RINGS
 BOOLEAN ndDivBy(number, number, const coeffs) { return TRUE; } // assume a,b !=0
@@ -216,4 +217,7 @@
     //n->cfKillChar = ndKillChar; /* dummy */
     // temp. removed to catch all the coeffs which miss to implement this!
+
+    n->cfChineseRemainder = ndChineseRemainder;
+    n->cfFarey = ndGcd;
 
 #ifdef HAVE_RINGS
