Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
| Download
GAP 4.8.9 installation with standard packages -- copy to your CoCalc project to get it
Project: cocalc-sagemath-dev-slelievre
Views: 418346/* Auxiliary functions for C++-style input of GMP types.12Copyright 2001 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 either:89* the GNU Lesser General Public License as published by the Free10Software Foundation; either version 3 of the License, or (at your11option) any later version.1213or1415* the GNU General Public License as published by the Free Software16Foundation; either version 2 of the License, or (at your option) any17later version.1819or both in parallel, as here.2021The GNU MP Library is distributed in the hope that it will be useful, but22WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY23or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License24for more details.2526You should have received copies of the GNU General Public License and the27GNU Lesser General Public License along with the GNU MP Library. If not,28see https://www.gnu.org/licenses/. */2930#include <cctype>31#include <iostream>32#include <string>33#include "gmp.h"34#include "gmp-impl.h"3536using namespace std;373839int40__gmp_istream_set_base (istream &i, char &c, bool &zero, bool &showbase)41{42int base;4344zero = showbase = false;45switch (i.flags() & ios::basefield)46{47case ios::dec:48base = 10;49break;50case ios::hex:51base = 16;52break;53case ios::oct:54base = 8;55break;56default:57showbase = true; // look for initial "0" or "0x" or "0X"58if (c == '0')59{60if (! i.get(c))61c = 0; // reset or we might loop indefinitely6263if (c == 'x' || c == 'X')64{65base = 16;66i.get(c);67}68else69{70base = 8;71zero = true; // if no other digit is read, the "0" counts72}73}74else75base = 10;76break;77}7879return base;80}8182void83__gmp_istream_set_digits (string &s, istream &i, char &c, bool &ok, int base)84{85switch (base)86{87case 10:88while (isdigit(c))89{90ok = true; // at least a valid digit was read91s += c;92if (! i.get(c))93break;94}95break;96case 8:97while (isdigit(c) && c != '8' && c != '9')98{99ok = true; // at least a valid digit was read100s += c;101if (! i.get(c))102break;103}104break;105case 16:106while (isxdigit(c))107{108ok = true; // at least a valid digit was read109s += c;110if (! i.get(c))111break;112}113break;114}115}116117118