Skip to content

Commit aad4fed

Browse files
committed
Document floating point descriptions.
Fixes <rdar://problem/51409021>.
1 parent e024d96 commit aad4fed

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

stdlib/public/core/FloatingPointTypes.swift.gyb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,12 @@ public struct ${Self} {
9292
${Availability(bits)}
9393
extension ${Self}: CustomStringConvertible {
9494
/// A textual representation of the value.
95+
///
96+
/// For all finite values, the value of this property is a string that can
97+
/// be converted back to an instance of ${Self} without rounding errors.
98+
/// That is, if `x` in a `${Self}`, then `${Self}(x.description) == x` is
99+
/// always true. For any NaN value, the property's value is "nan", and for
100+
/// positive and negative infinity its value is "inf" and "-inf".
95101
public var description: String {
96102
if isNaN {
97103
return "nan"
@@ -108,6 +114,9 @@ extension ${Self}: CustomStringConvertible {
108114
${Availability(bits)}
109115
extension ${Self}: CustomDebugStringConvertible {
110116
/// A textual representation of the value, suitable for debugging.
117+
///
118+
/// This property has the same value as the `description` propyrty, except
119+
/// that NaN values are printed in an extended format.
111120
public var debugDescription: String {
112121
var (buffer, length) = _float${bits}ToString(self, debug: true)
113122
return buffer.withBytes { (bufferPtr) in

0 commit comments

Comments
 (0)