mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-07-26 05:59:22 +08:00
17 lines
384 B
Java
17 lines
384 B
Java
package com.thealgorithms.maths;
|
|
|
|
public final class AbsoluteValue {
|
|
private AbsoluteValue() {
|
|
}
|
|
|
|
/**
|
|
* Returns the absolute value of a number.
|
|
*
|
|
* @param number The number to be transformed
|
|
* @return The absolute value of the {@code number}
|
|
*/
|
|
public static int getAbsValue(int number) {
|
|
return number < 0 ? -number : number;
|
|
}
|
|
}
|