diff --git a/kotlin-native/runtime/src/main/kotlin/kotlin/Primitives.kt b/kotlin-native/runtime/src/main/kotlin/kotlin/Primitives.kt index 42979608aa2..466db389745 100644 --- a/kotlin-native/runtime/src/main/kotlin/kotlin/Primitives.kt +++ b/kotlin-native/runtime/src/main/kotlin/kotlin/Primitives.kt @@ -1753,6 +1753,14 @@ public final class Float private constructor() : Number(), Comparable { public override fun equals(other: Any?): Boolean = other is Float && this.equals(other) + /** + * Returns the string representation of this [Float] value. + * + * Note that the representation format is unstable and may change in a future release. + * However, it is guaranteed that the returned string is valid for converting back to [Float] + * using [String.toFloat], and will result in the same numeric value. + * The exact bit pattern of a `NaN` float is not guaranteed to be preserved though. + */ public override fun toString() = NumberConverter.convert(this) public override fun hashCode(): Int = toBits() @@ -2063,6 +2071,14 @@ public final class Double private constructor() : Number(), Comparable { public override fun equals(other: Any?): Boolean = other is Double && this.equals(other) + /** + * Returns the string representation of this [Double] value. + * + * Note that the representation format is unstable and may change in a future release. + * However, it is guaranteed that the returned string is valid for converting back to [Double] + * using [String.toDouble], and will result in the same numeric value. + * The exact bit pattern of a `NaN` double is not guaranteed to be preserved though. + */ public override fun toString(): String = NumberConverter.convert(this) public override fun hashCode(): Int = toBits().hashCode() diff --git a/kotlin-native/runtime/src/main/kotlin/kotlin/native/internal/NumberConverter.kt b/kotlin-native/runtime/src/main/kotlin/kotlin/native/internal/NumberConverter.kt index 555053d8be2..19a89ec8992 100644 --- a/kotlin-native/runtime/src/main/kotlin/kotlin/native/internal/NumberConverter.kt +++ b/kotlin-native/runtime/src/main/kotlin/kotlin/native/internal/NumberConverter.kt @@ -27,7 +27,7 @@ private external fun ceil(x: Double): Double /** * Converts [Float] or [Double] numbers to the [String] representation */ -class NumberConverter { +internal class NumberConverter { private var setCount: Int = 0 // Number of times u and k have been gotten.