From 9a7268bad3d6210e7afe005010f9350c8876dd9d Mon Sep 17 00:00:00 2001 From: ploc <ploc@garoche.net> Date: Thu, 22 Jun 2017 08:22:46 -0700 Subject: [PATCH] io_frontend header with new functions --- include/io_frontend.h | 5 ++++- include/io_frontend.hpp | 21 ++++++++++++++++++--- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/include/io_frontend.h b/include/io_frontend.h index 01a93d73..09084965 100644 --- a/include/io_frontend.h +++ b/include/io_frontend.h @@ -23,6 +23,9 @@ extern void _put_bool(FILE* file, char* n, _Bool _V); extern void _put_int(FILE* file, char* n, int _V); /*@ assigns \nothing; */ -extern void _put_double(FILE* file, char* n, double _V); +extern void _put_float(FILE* file, char* n, float _V, int PREC); + +/*@ assigns \nothing; */ +extern void _put_double(FILE* file, char* n, double _V, int PREC); #endif diff --git a/include/io_frontend.hpp b/include/io_frontend.hpp index 0450f44d..b02385e2 100644 --- a/include/io_frontend.hpp +++ b/include/io_frontend.hpp @@ -80,15 +80,30 @@ void _put_int(FILE* file, char* n, int _V){ printf("\n"); fprintf(file, "%d\n", _V); } -void _put_double(FILE* file, char* n, double _V){ + +void _put_float(FILE* file, char* n, float _V, int PREC){ + if(ISATTY) { + printf("%s = ", n); + } else { + printf("'%s': ", n); + }; + printf("'%.*f' ", PREC, _V); + printf("\n"); + fprintf(file, "%.*f\n", PREC, _V); + fflush(file); +} + +void _put_double(FILE* file, char* n, double _V, int PREC){ if(ISATTY) { printf("%s = ", n); } else { printf("'%s': ", n); }; - printf("'%f' ", _V); + printf("'%.*f' ", PREC, _V); printf("\n"); - fprintf(file, "%f\n", _V); + fprintf(file, "%.*f\n", PREC, _V); + fflush(file); } + #endif -- GitLab