Prohibited NaN steps.

This commit is contained in:
Evgeny Gerashchenko
2013-02-13 16:21:20 +04:00
parent 4043491ad2
commit 021496c07d
4 changed files with 18 additions and 0 deletions
+2
View File
@@ -139,11 +139,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")
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")
checkStepIsPositive(step > 0, step)
return DoubleProgression(start, end, step)
}