[K/N] Internalize NumberConverter

As a part of efforts to stabilize K/N stdlib.
This commit is contained in:
Abduqodiri Qurbonzoda
2023-04-06 17:42:01 +03:00
parent 2328cf5fcf
commit bd3f528da4
2 changed files with 17 additions and 1 deletions
@@ -1753,6 +1753,14 @@ public final class Float private constructor() : Number(), Comparable<Float> {
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<Double> {
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()
@@ -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.