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/* 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 either:1213* the GNU Lesser General Public License as published by the Free14Software Foundation; either version 3 of the License, or (at your15option) any later version.1617or1819* the GNU General Public License as published by the Free Software20Foundation; either version 2 of the License, or (at your option) any21later version.2223or both in parallel, as here.2425The GNU MP Library is distributed in the hope that it will be useful, but26WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY27or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License28for more details.2930You should have received copies of the GNU General Public License and the31GNU Lesser General Public License along with the GNU MP Library. If not,32see https://www.gnu.org/licenses/. */3334#include <iostream>35#include <stdarg.h> /* for va_list and hence doprnt_funs_t */36#include <string.h>3738#include "gmp.h"39#include "gmp-impl.h"4041using namespace std;424344/* Don't need "format" for operator<< routines, just "memory" and "reps".45Omitting gmp_asprintf_format lets us avoid dragging vsnprintf into the46link. __gmp_asprintf_final will be called directly and doesn't need to47be in the struct. */4849const struct doprnt_funs_t __gmp_asprintf_funs_noformat = {50NULL,51(doprnt_memory_t) __gmp_asprintf_memory,52(doprnt_reps_t) __gmp_asprintf_reps,53NULL54};555657void58__gmp_doprnt_params_from_ios (struct doprnt_params_t *p, ios &o)59{60if ((o.flags() & ios::basefield) == ios::hex)61{62p->expfmt = "@%c%02d";63p->base = (o.flags() & ios::uppercase ? -16 : 16);64}65else66{67p->expfmt = (o.flags() & ios::uppercase ? "E%c%02d" : "e%c%02d");68if ((o.flags() & ios::basefield) == ios::oct)69p->base = 8;70else71p->base = 10;72}7374/* "general" if none or more than one bit set */75if ((o.flags() & ios::floatfield) == ios::fixed)76p->conv = DOPRNT_CONV_FIXED;77else if ((o.flags() & ios::floatfield) == ios::scientific)78p->conv = DOPRNT_CONV_SCIENTIFIC;79else80p->conv = DOPRNT_CONV_GENERAL;8182p->exptimes4 = 0;8384p->fill = o.fill();8586/* "right" if more than one bit set */87if ((o.flags() & ios::adjustfield) == ios::left)88p->justify = DOPRNT_JUSTIFY_LEFT;89else if ((o.flags() & ios::adjustfield) == ios::internal)90p->justify = DOPRNT_JUSTIFY_INTERNAL;91else92p->justify = DOPRNT_JUSTIFY_RIGHT;9394/* ios::fixed allows prec==0, others take 0 as the default 6.95Don't allow negatives (they do bad things to __gmp_doprnt_float_cxx). */96p->prec = MAX (0, o.precision());97if (p->prec == 0 && p->conv != DOPRNT_CONV_FIXED)98p->prec = 6;99100/* for hex showbase is always, for octal only non-zero */101if (o.flags() & ios::showbase)102p->showbase = ((o.flags() & ios::basefield) == ios::hex103? DOPRNT_SHOWBASE_YES : DOPRNT_SHOWBASE_NONZERO);104else105p->showbase = DOPRNT_SHOWBASE_NO;106107p->showpoint = ((o.flags() & ios::showpoint) != 0);108109/* in fixed and scientific always show trailing zeros, in general format110show them if showpoint is set (or so it seems) */111if ((o.flags() & ios::floatfield) == ios::fixed112|| (o.flags() & ios::floatfield) == ios::scientific)113p->showtrailing = 1;114else115p->showtrailing = p->showpoint;116117p->sign = (o.flags() & ios::showpos ? '+' : '\0');118119p->width = o.width();120121/* reset on each output */122o.width (0);123}124125126