Make isNaN check language independent, working in JVM & JS

This commit is contained in:
Ilya Ryzhenkov
2014-04-18 19:20:33 +04:00
committed by Andrey Breslav
parent a825b13a4b
commit a6c01f82b2
2 changed files with 15 additions and 2 deletions
+13
View File
@@ -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
+2 -2
View File
@@ -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)
}