File tree Expand file tree Collapse file tree 2 files changed +27
-20
lines changed Expand file tree Collapse file tree 2 files changed +27
-20
lines changed Original file line number Diff line number Diff line change @@ -121,9 +121,16 @@ cube_out(NDBOX * cube)
121
121
bool equal = true;
122
122
int dim = cube -> dim ;
123
123
int i ;
124
+ int ndig ;
124
125
125
126
initStringInfo (& buf );
126
127
128
+ /*
129
+ * Get the number of digits to display.
130
+ */
131
+ ndig = DBL_DIG + extra_float_digits ;
132
+ if (ndig < 1 ) ndig = 1 ;
133
+
127
134
/*
128
135
* while printing the first (LL) corner, check if it is equal to the
129
136
* second one
@@ -133,7 +140,7 @@ cube_out(NDBOX * cube)
133
140
{
134
141
if (i > 0 )
135
142
appendStringInfo (& buf , ", " );
136
- appendStringInfo (& buf , "%.16g" , cube -> x [i ]);
143
+ appendStringInfo (& buf , "%.*g" , ndig , cube -> x [i ]);
137
144
if (cube -> x [i ] != cube -> x [i + dim ])
138
145
equal = false;
139
146
}
@@ -146,7 +153,7 @@ cube_out(NDBOX * cube)
146
153
{
147
154
if (i > 0 )
148
155
appendStringInfo (& buf , ", " );
149
- appendStringInfo (& buf , "%.16g" , cube -> x [i + dim ]);
156
+ appendStringInfo (& buf , "%.*g" , ndig , cube -> x [i + dim ]);
150
157
}
151
158
appendStringInfoChar (& buf , ')' );
152
159
}
Original file line number Diff line number Diff line change @@ -145,39 +145,39 @@ SELECT '-1e-700'::cube AS cube;
145
145
(1 row)
146
146
147
147
SELECT '1234567890123456'::cube AS cube;
148
- cube
149
- --------------------
150
- (1234567890123456 )
148
+ cube
149
+ ------------------------
150
+ (1.23456789012346e+15 )
151
151
(1 row)
152
152
153
153
SELECT '+1234567890123456'::cube AS cube;
154
- cube
155
- --------------------
156
- (1234567890123456 )
154
+ cube
155
+ ------------------------
156
+ (1.23456789012346e+15 )
157
157
(1 row)
158
158
159
159
SELECT '-1234567890123456'::cube AS cube;
160
- cube
161
- ---------------------
162
- (-1234567890123456 )
160
+ cube
161
+ -------------------------
162
+ (-1.23456789012346e+15 )
163
163
(1 row)
164
164
165
165
SELECT '.1234567890123456'::cube AS cube;
166
- cube
167
- ----------------------
168
- (0.1234567890123456 )
166
+ cube
167
+ ---------------------
168
+ (0.123456789012346 )
169
169
(1 row)
170
170
171
171
SELECT '+.1234567890123456'::cube AS cube;
172
- cube
173
- ----------------------
174
- (0.1234567890123456 )
172
+ cube
173
+ ---------------------
174
+ (0.123456789012346 )
175
175
(1 row)
176
176
177
177
SELECT '-.1234567890123456'::cube AS cube;
178
- cube
179
- -----------------------
180
- (-0.1234567890123456 )
178
+ cube
179
+ ----------------------
180
+ (-0.123456789012346 )
181
181
(1 row)
182
182
183
183
-- simple lists (points)
You can’t perform that action at this time.
0 commit comments