sign

inline fun <T : Number> Array<T>.sign(): DoubleArray

Returns the sign of the given value Array:

  • -1.0 if the value is negative,

  • zero if the value is zero,

  • 1.0 if the value is positive

Example:

arrayOf(-1.0, 2.0, 0.0, -6.0).sign() // [-1.0, 1.0, 0.0, -1.0]

Since

1.1.0

See also

sign

inline fun <T : Number> Iterable<T>.sign(): Iterable<Double>

Returns the sign of the given value Iterable:

  • -1.0 if the value is negative,

  • zero if the value is zero,

  • 1.0 if the value is positive

Example:

listOf(-1.0, 2.0, 0.0, -6.0).sign() // [-1.0, 1.0, 0.0, -1.0]

Since

1.1.0

See also

sign