@@ -141,12 +141,15 @@ static int swift_snprintf_l(char *Str, size_t StrSize, locale_t Locale,
141
141
142
142
template <typename T>
143
143
static uint64_t swift_floatingPointToString (char *Buffer, size_t BufferLength,
144
- T Value, const char *Format) {
144
+ T Value, const char *Format, bool Debug ) {
145
145
if (BufferLength < 32 )
146
146
swift::crash (" swift_floatingPointToString: insufficient buffer size" );
147
147
148
- const int Precision = std::numeric_limits<T>::max_digits10;
149
-
148
+ int Precision = std::numeric_limits<T>::digits10;
149
+ if (Debug) {
150
+ Precision = std::numeric_limits<T>::max_digits10;
151
+ }
152
+
150
153
// Pass a null locale to use the C locale.
151
154
int i = swift_snprintf_l (Buffer, BufferLength, /* locale=*/ nullptr , Format,
152
155
Precision, Value);
@@ -170,21 +173,21 @@ static uint64_t swift_floatingPointToString(char *Buffer, size_t BufferLength,
170
173
}
171
174
172
175
extern " C" uint64_t swift_float32ToString (char *Buffer, size_t BufferLength,
173
- float Value) {
176
+ float Value, bool Debug ) {
174
177
return swift_floatingPointToString<float >(Buffer, BufferLength, Value,
175
- " %0.*g" );
178
+ " %0.*g" , Debug );
176
179
}
177
180
178
181
extern " C" uint64_t swift_float64ToString (char *Buffer, size_t BufferLength,
179
- double Value) {
182
+ double Value, bool Debug ) {
180
183
return swift_floatingPointToString<double >(Buffer, BufferLength, Value,
181
- " %0.*g" );
184
+ " %0.*g" , Debug );
182
185
}
183
186
184
187
extern " C" uint64_t swift_float80ToString (char *Buffer, size_t BufferLength,
185
- long double Value) {
188
+ long double Value, bool Debug ) {
186
189
return swift_floatingPointToString<long double >(Buffer, BufferLength, Value,
187
- " %0.*Lg" );
190
+ " %0.*Lg" , Debug );
188
191
}
189
192
190
193
// / \param[out] LinePtr Replaced with the pointer to the malloc()-allocated
0 commit comments