public class MathUtils extends Object
| 构造器和说明 |
|---|
MathUtils() |
| 限定符和类型 | 方法和说明 |
|---|---|
static boolean |
isPowerOf2(long value)
Checks whether the given value is a power of two.
|
static int |
log2strict(int value)
Computes the logarithm of the given value to the base of 2.
|
static Integer |
max(Integer v1,
Integer v2) |
static Integer |
min(Integer v1,
Integer v2) |
static int |
roundDownToPowerOf2(int value)
Decrements the given number down to the closest power of two.
|
public static int roundDownToPowerOf2(int value)
value - The value to round down.public static boolean isPowerOf2(long value)
value - The value to check.public static int log2strict(int value)
throws ArithmeticException,
IllegalArgumentException
value - The value to compute the logarithm for.ArithmeticException - Thrown, if the given value is zero.IllegalArgumentException - Thrown, if the given value is not a power of two.Copyright © 2023–2024 The Apache Software Foundation. All rights reserved.