Make isNaN check language independent, working in JVM & JS
This commit is contained in:
committed by
Andrey Breslav
parent
a825b13a4b
commit
a6c01f82b2
@@ -0,0 +1,13 @@
|
||||
package kotlin
|
||||
|
||||
/**
|
||||
* Returns {@code true} if the specified number is a
|
||||
* Not-a-Number (NaN) value, {@code false} otherwise.
|
||||
*/
|
||||
fun Double.isNaN() = this != this
|
||||
|
||||
/**
|
||||
* Returns {@code true} if the specified number is a
|
||||
* Not-a-Number (NaN) value, {@code false} otherwise.
|
||||
*/
|
||||
fun Float.isNaN() = this != this
|
||||
@@ -135,13 +135,13 @@ public fun LongRange.step(step: Long): LongProgression {
|
||||
}
|
||||
|
||||
public fun FloatRange.step(step: Float): FloatProgression {
|
||||
if (java.lang.Float.isNaN(step)) throw IllegalArgumentException("Step must not be NaN")
|
||||
if (step.isNaN()) throw IllegalArgumentException("Step must not be NaN")
|
||||
checkStepIsPositive(step > 0, step)
|
||||
return FloatProgression(start, end, step)
|
||||
}
|
||||
|
||||
public fun DoubleRange.step(step: Double): DoubleProgression {
|
||||
if (java.lang.Double.isNaN(step)) throw IllegalArgumentException("Step must not be NaN")
|
||||
if (step.isNaN()) throw IllegalArgumentException("Step must not be NaN")
|
||||
checkStepIsPositive(step > 0, step)
|
||||
return DoubleProgression(start, end, step)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user