GAP 4.8.9 installation with standard packages -- copy to your CoCalc project to get it
/* operator>> -- C++-style input of mpq_t.12Copyright 2003 Free Software Foundation, Inc.34This file is part of the GNU MP Library.56The GNU MP Library is free software; you can redistribute it and/or modify7it under the terms of the GNU Lesser General Public License as published by8the Free Software Foundation; either version 2.1 of the License, or (at your9option) any later version.1011The GNU MP Library is distributed in the hope that it will be useful, but12WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY13or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public14License for more details.1516You should have received a copy of the GNU Lesser General Public License17along with the GNU MP Library; see the file COPYING.LIB. If not, write to18the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,19MA 02110-1301, USA. */2021#include <cctype>22#include <iostream>23#include <string>24#include "gmp.h"25#include "gmp-impl.h"2627using namespace std;282930istream &31operator>> (istream &i, mpq_ptr q)32{33if (! (i >> mpq_numref(q)))34return i;3536char c = 0;37i.get(c); // start reading3839if (c == '/')40{41// skip slash, read denominator42i.get(c);43return __gmpz_operator_in_nowhite (i, mpq_denref(q), c);44}45else46{47// no denominator, set 148q->_mp_den._mp_size = 1;49q->_mp_den._mp_d[0] = 1;50if (i.good())51i.putback(c);52else if (i.eof())53i.clear();54}5556return i;57}585960