From 5bceb50278f767e8808a761c48d7b028e4ddc1d5 Mon Sep 17 00:00:00 2001 From: pranaygupta36 <pranayguptastudent@gmail.com> Date: Thu, 24 May 2018 16:54:00 +0530 Subject: [PATCH] float specifier defined to align floating point numbers while printing --- pd/src/d_misc.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/pd/src/d_misc.c b/pd/src/d_misc.c index 444986ea2..c86a0f37f 100644 --- a/pd/src/d_misc.c +++ b/pd/src/d_misc.c @@ -9,6 +9,13 @@ #include <stdio.h> #include <string.h> +// an attempt to align floating point numbers in columns +#if PD_FLOATSIZE == 32 +#define FLOAT_SPECIFIER "%#-.6g \t" +#elif PD_FLOATSIZE == 64 +#define FLOAT_SPECIFIER "%#-.9lg \t" +#endif + /* ------------------------- print~ -------------------------- */ static t_class *print_class; @@ -30,8 +37,8 @@ static t_int *print_perform(t_int *w) int i=0; startpost("%s:", x->x_sym->s_name); for(i=0; i<n; i++) { - if(i%8==0)endpost(); - startpost("%-8.5g", in[i]); + if(i%4==0)endpost(); + startpost(FLOAT_SPECIFIER, in[i]); } endpost(); x->x_count--; -- GitLab