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
{
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;
}
{
if (i > 0)
appendStringInfo(&buf, ", ");
- appendStringInfo(&buf, "%.16g", cube->x[i + dim]);
+ appendStringInfo(&buf, "%.*g", ndig, cube->x[i + dim]);
}
appendStringInfoChar(&buf, ')');
}
(1 row)
SELECT '1234567890123456'::cube AS cube;
- cube
---------------------
- (1234567890123456)
+ cube
+------------------------
+ (1.23456789012346e+15)
(1 row)
SELECT '+1234567890123456'::cube AS cube;
- cube
---------------------
- (1234567890123456)
+ cube
+------------------------
+ (1.23456789012346e+15)
(1 row)
SELECT '-1234567890123456'::cube AS cube;
- cube
----------------------
- (-1234567890123456)
+ cube
+-------------------------
+ (-1.23456789012346e+15)
(1 row)
SELECT '.1234567890123456'::cube AS cube;
- cube
-----------------------
- (0.1234567890123456)
+ cube
+---------------------
+ (0.123456789012346)
(1 row)
SELECT '+.1234567890123456'::cube AS cube;
- cube
-----------------------
- (0.1234567890123456)
+ cube
+---------------------
+ (0.123456789012346)
(1 row)
SELECT '-.1234567890123456'::cube AS cube;
- cube
------------------------
- (-0.1234567890123456)
+ cube
+----------------------
+ (-0.123456789012346)
(1 row)
-- simple lists (points)