sign

inline actual fun sign(x: Double): Double (source)

Platform and version requirements: Kotlin 1.2

inline actual fun sign(x: Float): Float (source)

Platform and version requirements: Kotlin 1.2

Returns the sign of the given value x:

  • -1.0 if the value is negative,
  • zero if the value is zero,
  • 1.0 if the value is positive

Special case:

  • sign(NaN) is NaN
inline actual val Double.sign: Double (source)

Platform and version requirements: Kotlin 1.2

inline actual val Float.sign: Float (source)

Platform and version requirements: Kotlin 1.2

Returns the sign of this value:

  • -1.0 if the value is negative,
  • zero if the value is zero,
  • 1.0 if the value is positive

Special case:

  • NaN.sign is NaN
actual val Int.sign: Int (source)

Platform and version requirements: Kotlin 1.2

actual val Long.sign: Int (source)

Platform and version requirements: Kotlin 1.2

Returns the sign of this value:

  • -1 if the value is negative,
  • 0 if the value is zero,
  • 1 if the value is positive