Skip to content

Commit 10b61b7

Browse files
committed
Made floating point numbers conform to CustomDebugStringConvertible
debugDescription prints numbers with greater precision
1 parent e4fe5f1 commit 10b61b7

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

stdlib/public/core/FloatingPoint.swift.gyb

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,14 @@ public struct ${Self} {
198198
extension ${Self} : CustomStringConvertible {
199199
/// A textual representation of `self`.
200200
public var description: String {
201-
return _float${bits}ToString(self)
201+
return _float${bits}ToString(self, debug: false)
202+
}
203+
}
204+
205+
extension ${Self} : CustomDebugStringConvertible {
206+
/// A textual representation of `self`.
207+
public var debugDescription: String {
208+
return _float${bits}ToString(self, debug: true)
202209
}
203210
}
204211

stdlib/public/stubs/Stubs.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,8 @@ static int swift_snprintf_l(char *Str, size_t StrSize, locale_t Locale,
141141

142142
template <typename T>
143143
static uint64_t swift_floatingPointToString(char *Buffer, size_t BufferLength,
144-
T Value, const char *Format, bool Debug) {
144+
T Value, const char *Format,
145+
bool Debug) {
145146
if (BufferLength < 32)
146147
swift::crash("swift_floatingPointToString: insufficient buffer size");
147148

0 commit comments

Comments
 (0)