aboutsummaryrefslogtreecommitdiff
path: root/contrib/cube/cube.c
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/cube/cube.c')
-rw-r--r--contrib/cube/cube.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/contrib/cube/cube.c b/contrib/cube/cube.c
index 98c6167e625..d24d0f55932 100644
--- a/contrib/cube/cube.c
+++ b/contrib/cube/cube.c
@@ -121,10 +121,17 @@ cube_out(NDBOX * cube)
bool equal = true;
int dim = cube->dim;
int i;
+ int ndig;
initStringInfo(&buf);
/*
+ * Get the number of digits to display.
+ */
+ ndig = DBL_DIG + extra_float_digits;
+ if (ndig < 1) ndig = 1;
+
+ /*
* while printing the first (LL) corner, check if it is equal to the
* second one
*/
@@ -133,7 +140,7 @@ cube_out(NDBOX * cube)
{
if (i > 0)
appendStringInfo(&buf, ", ");
- appendStringInfo(&buf, "%.16g", cube->x[i]);
+ appendStringInfo(&buf, "%.*g", ndig, cube->x[i]);
if (cube->x[i] != cube->x[i + dim])
equal = false;
}
@@ -146,7 +153,7 @@ cube_out(NDBOX * cube)
{
if (i > 0)
appendStringInfo(&buf, ", ");
- appendStringInfo(&buf, "%.16g", cube->x[i + dim]);
+ appendStringInfo(&buf, "%.*g", ndig, cube->x[i + dim]);
}
appendStringInfoChar(&buf, ')');
}