abs

fun abs(a: Float): Float

Returns the absolute value of a float value. If the argument is not negative, the argument is returned. If the argument is negative, the negation of the argument is returned. Special cases:

  • If the argument is positive zero or negative zero, the result is positive zero.

  • If the argument is infinite, the result is positive infinity.

  • If the argument is NaN, the result is NaN.

Return

the absolute value of the argument.

Parameters

a

the argument whose absolute value is to be determined


fun abs(a: Double): Double

Returns the absolute value of a double value. If the argument is not negative, the argument is returned. If the argument is negative, the negation of the argument is returned. Special cases:

  • If the argument is positive zero or negative zero, the result is positive zero.

  • If the argument is infinite, the result is positive infinity.

  • If the argument is NaN, the result is NaN.

Return

the absolute value of the argument.

Parameters

a

the argument whose absolute value is to be determined