diff options
author | Pádraig Brady <P@draigBrady.com> | 2013-06-18 15:47:35 +0100 |
---|---|---|
committer | Pádraig Brady <P@draigBrady.com> | 2013-06-18 16:18:56 +0100 |
commit | 2bb800dd414038f233576acf53c0f2fd0d3609cd (patch) | |
tree | d41b68911aff9d49fbcc9a090cd2efa54dc9de1e /src | |
parent | 84f497195cc0bbf2dda7a88631f55ad7c3934383 (diff) | |
download | coreutils-2bb800dd414038f233576acf53c0f2fd0d3609cd.tar.xz |
tests: use appropriate precision when printing float limits
* src/getlimits.c (print_float): Adjust to use the ftoastr module,
which uses the appropriate precision so that no info is lost.
* cfg.mk (sc_prohibit_continued_string_alpha_in_column_1): Exclude od.c
fixes http://bugs.gnu.org/14650
Diffstat (limited to 'src')
-rw-r--r-- | src/getlimits.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/src/getlimits.c b/src/getlimits.c index 7c1fbe26e..99140255f 100644 --- a/src/getlimits.c +++ b/src/getlimits.c @@ -21,6 +21,7 @@ #include <sys/types.h> #include <float.h> +#include "ftoastr.h" #include "system.h" #include "long-options.h" @@ -97,6 +98,19 @@ decimal_absval_add_one (char *buf) return result; } +#define PRINT_FLOATTYPE(N, T, FTOASTR, BUFSIZE) \ +static void \ +N (T x) \ +{ \ + char buf[BUFSIZE]; \ + FTOASTR (buf, sizeof buf, FTOASTR_LEFT_JUSTIFY, 0, x); \ + puts (buf); \ +} + +PRINT_FLOATTYPE (print_FLT, float, ftoastr, FLT_BUFSIZE_BOUND) +PRINT_FLOATTYPE (print_DBL, double, dtoastr, DBL_BUFSIZE_BOUND) +PRINT_FLOATTYPE (print_LDBL, long double, ldtoastr, LDBL_BUFSIZE_BOUND) + int main (int argc, char **argv) { @@ -127,8 +141,8 @@ main (int argc, char **argv) } #define print_float(TYPE) \ - printf (#TYPE"_MIN=%Le\n", (long double)TYPE##_MIN); \ - printf (#TYPE"_MAX=%Le\n", (long double)TYPE##_MAX); + printf (#TYPE"_MIN="); print_##TYPE (TYPE##_MIN); \ + printf (#TYPE"_MAX="); print_##TYPE (TYPE##_MAX); /* Variable sized ints */ print_int (CHAR); |