W3cubDocs

/Kotlin

sign

inline fun sign(x: Double): Double

Platform and version requirements: Kotlin 1.2

inline fun sign(x: Float): Float

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 val Double.sign: Double

Platform and version requirements: Kotlin 1.2

inline val Float.sign: Float

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
val Int.sign: Int

Platform and version requirements: Kotlin 1.2

val Long.sign: Int

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

© 2010–2018 JetBrains s.r.o.
Licensed under the Apache License, Version 2.0.
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.math/sign.html