Provide isInfinite() and isFinite() functions for Double and Float.

#KT-7126 Fixed
This commit is contained in:
Ilya Gorbunov
2015-04-17 17:39:57 +03:00
parent 5dacb5a745
commit 592e6582b3
2 changed files with 59 additions and 1 deletions
+22 -1
View File
@@ -10,4 +10,25 @@ public fun Double.isNaN(): Boolean = this != this
* Returns `true` if the specified number is a
* Not-a-Number (NaN) value, `false` otherwise.
*/
public fun Float.isNaN(): Boolean = this != this
public fun Float.isNaN(): Boolean = this != this
/**
* Returns `true` if this value is infinitely large in magnitude.
*/
public fun Double.isInfinite(): Boolean = this == Double.POSITIVE_INFINITY || this == Double.NEGATIVE_INFINITY
/**
* Returns `true` if this value is infinitely large in magnitude.
*/
public fun Float.isInfinite(): Boolean = this == Float.POSITIVE_INFINITY || this == Float.NEGATIVE_INFINITY
/**
* Returns `true` if the argument is a finite floating-point value; returns `false` otherwise (for `NaN` and infinity arguments).
*/
public fun Double.isFinite(): Boolean = !isInfinite() && !isNaN()
/**
* Returns `true` if the argument is a finite floating-point value; returns `false` otherwise (for `NaN` and infinity arguments).
*/
public fun Float.isFinite(): Boolean = !isInfinite() && !isNaN()