GAP 4.8.9 installation with standard packages -- copy to your CoCalc project to get it
/* Support for operator<< routines.12THE FUNCTIONS IN THIS FILE ARE FOR INTERNAL USE ONLY. THEY'RE ALMOST3CERTAIN TO BE SUBJECT TO INCOMPATIBLE CHANGES OR DISAPPEAR COMPLETELY IN4FUTURE GNU MP RELEASES.56Copyright 2001 Free Software Foundation, Inc.78This file is part of the GNU MP Library.910The GNU MP Library is free software; you can redistribute it and/or modify11it under the terms of the GNU Lesser General Public License as published by12the Free Software Foundation; either version 2.1 of the License, or (at your13option) any later version.1415The GNU MP Library is distributed in the hope that it will be useful, but16WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY17or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public18License for more details.1920You should have received a copy of the GNU Lesser General Public License21along with the GNU MP Library; see the file COPYING.LIB. If not, write to22the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,23MA 02110-1301, USA. */2425#include <iostream>26#include <stdarg.h> /* for va_list and hence doprnt_funs_t */27#include <string.h>2829#include "gmp.h"30#include "gmp-impl.h"3132using namespace std;333435/* Don't need "format" for operator<< routines, just "memory" and "reps".36Omitting gmp_asprintf_format lets us avoid dragging vsnprintf into the37link. __gmp_asprintf_final will be called directly and doesn't need to38be in the struct. */3940const struct doprnt_funs_t __gmp_asprintf_funs_noformat = {41NULL,42(doprnt_memory_t) __gmp_asprintf_memory,43(doprnt_reps_t) __gmp_asprintf_reps,44NULL45};464748void49__gmp_doprnt_params_from_ios (struct doprnt_params_t *p, ios &o)50{51if ((o.flags() & ios::basefield) == ios::hex)52{53p->expfmt = "@%c%02d";54p->base = (o.flags() & ios::uppercase ? -16 : 16);55}56else57{58p->expfmt = (o.flags() & ios::uppercase ? "E%c%02d" : "e%c%02d");59if ((o.flags() & ios::basefield) == ios::oct)60p->base = 8;61else62p->base = 10;63}6465/* "general" if none or more than one bit set */66if ((o.flags() & ios::floatfield) == ios::fixed)67p->conv = DOPRNT_CONV_FIXED;68else if ((o.flags() & ios::floatfield) == ios::scientific)69p->conv = DOPRNT_CONV_SCIENTIFIC;70else71p->conv = DOPRNT_CONV_GENERAL;7273p->exptimes4 = 0;7475p->fill = o.fill();7677/* "right" if more than one bit set */78if ((o.flags() & ios::adjustfield) == ios::left)79p->justify = DOPRNT_JUSTIFY_LEFT;80else if ((o.flags() & ios::adjustfield) == ios::internal)81p->justify = DOPRNT_JUSTIFY_INTERNAL;82else83p->justify = DOPRNT_JUSTIFY_RIGHT;8485/* ios::fixed allows prec==0, others take 0 as the default 6.86Don't allow negatives (they do bad things to __gmp_doprnt_float_cxx). */87p->prec = MAX (0, o.precision());88if (p->prec == 0 && p->conv != DOPRNT_CONV_FIXED)89p->prec = 6;9091/* for hex showbase is always, for octal only non-zero */92if (o.flags() & ios::showbase)93p->showbase = ((o.flags() & ios::basefield) == ios::hex94? DOPRNT_SHOWBASE_YES : DOPRNT_SHOWBASE_NONZERO);95else96p->showbase = DOPRNT_SHOWBASE_NO;9798p->showpoint = ((o.flags() & ios::showpoint) != 0);99100/* in fixed and scientific always show trailing zeros, in general format101show them if showpoint is set (or so it seems) */102if ((o.flags() & ios::floatfield) == ios::fixed103|| (o.flags() & ios::floatfield) == ios::scientific)104p->showtrailing = 1;105else106p->showtrailing = p->showpoint;107108p->sign = (o.flags() & ios::showpos ? '+' : '\0');109110p->width = o.width();111112/* reset on each output */113o.width (0);114}115116117