From 0593d9331414beabdd0d97b3a1e4d4d841b5309f Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Thu, 16 Nov 2000 12:49:26 -0500 Subject: [svn-r2950] Purpose: Bug fix Description: The output of floating point dumps wasn't necessarily standard. The h5ls utility does it in a better way. Solution: Changed the output parameters from %g to %1.*g and added the appropriate FLT_DIG/DBL_DIG parameter for the `*' in the above. Platforms tested: Linux --- tools/h5dump.c | 4 ++-- tools/h5tools.c | 9 +++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/tools/h5dump.c b/tools/h5dump.c index 515e61c..f961555 100644 --- a/tools/h5dump.c +++ b/tools/h5dump.c @@ -47,8 +47,8 @@ static h5dump_t dataformat = { "%lu", /*fmt_ulong*/ NULL, /*fmt_llong*/ NULL, /*fmt_ullong*/ - "%g", /*fmt_double*/ - "%g", /*fmt_float*/ + "%1.*g", /*fmt_double*/ + "%1.*g", /*fmt_float*/ 0, /*ascii*/ 0, /*str_locale*/ diff --git a/tools/h5tools.c b/tools/h5tools.c index 2408470..293e403 100644 --- a/tools/h5tools.c +++ b/tools/h5tools.c @@ -713,10 +713,12 @@ h5dump_sprint(h5dump_str_t *str/*in,out*/, const h5dump_t *info, h5dump_str_append(str, OPT(info->fmt_raw, "%02x"), ucp_vp[i]); } else if (H5Tequal(type, H5T_NATIVE_DOUBLE)) { memcpy(&tempdouble, vp, sizeof(double)); - h5dump_str_append(str, OPT(info->fmt_double, "%g"), tempdouble); + h5dump_str_append(str, OPT(info->fmt_double, "%1.*g"), + DBL_DIG, tempdouble); } else if (H5Tequal(type, H5T_NATIVE_FLOAT)) { memcpy(&tempfloat, vp, sizeof(float)); - h5dump_str_append(str, OPT(info->fmt_double, "%g"), tempfloat); + h5dump_str_append(str, OPT(info->fmt_double, "%1.*g"), + FLT_DIG, tempfloat); } else if (info->ascii && (H5Tequal(type, H5T_NATIVE_SCHAR) || H5Tequal(type, H5T_NATIVE_UCHAR))) { @@ -757,8 +759,7 @@ h5dump_sprint(h5dump_str_t *str/*in,out*/, const h5dump_t *info, break; } } - - } else if (H5T_STRING==H5Tget_class(type)) { + } else if (H5T_STRING == H5Tget_class(type)) { unsigned int i; size = H5Tget_size(type); -- cgit v0.12