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)
121121 bool equal = true;
122122 int dim = cube -> dim ;
123123 int i ;
124+ int ndig ;
124125
125126 initStringInfo (& buf );
126127
128+ /*
129+ * Get the number of digits to display.
130+ */
131+ ndig = DBL_DIG + extra_float_digits ;
132+ if (ndig < 1 ) ndig = 1 ;
133+
127134 /*
128135 * while printing the first (LL) corner, check if it is equal to the
129136 * second one
@@ -133,7 +140,7 @@ cube_out(NDBOX * cube)
133140 {
134141 if (i > 0 )
135142 appendStringInfo (& buf , ", " );
136- appendStringInfo (& buf , "%.16g" , cube -> x [i ]);
143+ appendStringInfo (& buf , "%.*g" , ndig , cube -> x [i ]);
137144 if (cube -> x [i ] != cube -> x [i + dim ])
138145 equal = false;
139146 }
@@ -146,7 +153,7 @@ cube_out(NDBOX * cube)
146153 {
147154 if (i > 0 )
148155 appendStringInfo (& buf , ", " );
149- appendStringInfo (& buf , "%.16g" , cube -> x [i + dim ]);
156+ appendStringInfo (& buf , "%.*g" , ndig , cube -> x [i + dim ]);
150157 }
151158 appendStringInfoChar (& buf , ')' );
152159 }
Original file line number Diff line number Diff line change @@ -145,39 +145,39 @@ SELECT '-1e-700'::cube AS cube;
145145(1 row)
146146
147147SELECT '1234567890123456'::cube AS cube;
148- cube
149- --------------------
150- (1234567890123456 )
148+ cube
149+ ------------------------
150+ (1.23456789012346e+15 )
151151(1 row)
152152
153153SELECT '+1234567890123456'::cube AS cube;
154- cube
155- --------------------
156- (1234567890123456 )
154+ cube
155+ ------------------------
156+ (1.23456789012346e+15 )
157157(1 row)
158158
159159SELECT '-1234567890123456'::cube AS cube;
160- cube
161- ---------------------
162- (-1234567890123456 )
160+ cube
161+ -------------------------
162+ (-1.23456789012346e+15 )
163163(1 row)
164164
165165SELECT '.1234567890123456'::cube AS cube;
166- cube
167- ----------------------
168- (0.1234567890123456 )
166+ cube
167+ ---------------------
168+ (0.123456789012346 )
169169(1 row)
170170
171171SELECT '+.1234567890123456'::cube AS cube;
172- cube
173- ----------------------
174- (0.1234567890123456 )
172+ cube
173+ ---------------------
174+ (0.123456789012346 )
175175(1 row)
176176
177177SELECT '-.1234567890123456'::cube AS cube;
178- cube
179- -----------------------
180- (-0.1234567890123456 )
178+ cube
179+ ----------------------
180+ (-0.123456789012346 )
181181(1 row)
182182
183183-- simple lists (points)
You can’t perform that action at this time.
0 commit comments