Make Double and Float known values constant

#KT-13887
This commit is contained in:
Ilya Gorbunov
2020-01-21 17:02:49 +03:00
parent 435a7e7e26
commit 1c93911279
7 changed files with 79 additions and 65 deletions
+10 -20
View File
@@ -680,32 +680,27 @@ public class Float private constructor() : Number(), Comparable<Float> {
/**
* A constant holding the smallest *positive* nonzero value of Float.
*/
@Suppress("MUST_BE_INITIALIZED_OR_BE_ABSTRACT")
public val MIN_VALUE: Float
public const val MIN_VALUE: Float = 1.4E-45F
/**
* A constant holding the largest positive finite value of Float.
*/
@Suppress("MUST_BE_INITIALIZED_OR_BE_ABSTRACT")
public val MAX_VALUE: Float
public const val MAX_VALUE: Float = 3.4028235E38F
/**
* A constant holding the positive infinity value of Float.
*/
@Suppress("MUST_BE_INITIALIZED_OR_BE_ABSTRACT")
public val POSITIVE_INFINITY: Float
public const val POSITIVE_INFINITY: Float = 1.0F/0.0F
/**
* A constant holding the negative infinity value of Float.
*/
@Suppress("MUST_BE_INITIALIZED_OR_BE_ABSTRACT")
public val NEGATIVE_INFINITY: Float
public const val NEGATIVE_INFINITY: Float = -1.0F/0.0F
/**
* A constant holding the "not a number" value of Float.
*/
@Suppress("MUST_BE_INITIALIZED_OR_BE_ABSTRACT")
public val NaN: Float
public const val NaN: Float = -(0.0F/0.0F)
}
/**
@@ -890,32 +885,27 @@ public class Double private constructor() : Number(), Comparable<Double> {
/**
* A constant holding the smallest *positive* nonzero value of Double.
*/
@Suppress("MUST_BE_INITIALIZED_OR_BE_ABSTRACT")
public val MIN_VALUE: Double
public const val MIN_VALUE: Double = 4.9E-324
/**
* A constant holding the largest positive finite value of Double.
*/
@Suppress("MUST_BE_INITIALIZED_OR_BE_ABSTRACT")
public val MAX_VALUE: Double
public const val MAX_VALUE: Double = 1.7976931348623157E308
/**
* A constant holding the positive infinity value of Double.
*/
@Suppress("MUST_BE_INITIALIZED_OR_BE_ABSTRACT")
public val POSITIVE_INFINITY: Double
public const val POSITIVE_INFINITY: Double = 1.0/0.0
/**
* A constant holding the negative infinity value of Double.
*/
@Suppress("MUST_BE_INITIALIZED_OR_BE_ABSTRACT")
public val NEGATIVE_INFINITY: Double
public const val NEGATIVE_INFINITY: Double = -1.0/0.0
/**
* A constant holding the "not a number" value of Double.
*/
@Suppress("MUST_BE_INITIALIZED_OR_BE_ABSTRACT")
public val NaN: Double
public const val NaN: Double = -(0.0/0.0)
}
/**