public abstract class Util
extends java.lang.Object
| Constructor and Description |
|---|
Util() |
| Modifier and Type | Method and Description |
|---|---|
static int |
ffs(int v)
Find first set (least significant bit).
|
static int |
ffs(long v)
Find first set (least significant bit).
|
static int |
fls(int v)
Find last set (most significant bit).
|
static int |
fls(long v)
Find last set (most significant bit).
|
static int |
gcd(int u,
int v)
Returns the greatest common divisor of a pair of numbers.
|
static long |
gcd(long u,
long v)
Returns the greatest common divisor of a pair of numbers.
|
static int |
log2c(int v)
Returns ceil(log2(n))
|
static int |
popcount(int v)
Return the number of ones in the binary representation of the
value of the argument.
|
static int |
popcount(long v)
Return the number of ones in the binary representation of the
value of the argument.
|
static java.lang.String |
repeatString(java.lang.String s,
int n)
Repeat a given string a certain number of times.
|
static int |
zerocount(int v)
Return the number of zeros in the binary representation of the
value of the argument.
|
static int |
zerocount(long v)
Return the number of zeros in the binary representation of the
value of the argument.
|
public static final java.lang.String repeatString(java.lang.String s,
int n)
s repeated n
times.public static final int ffs(int v)
ffs(0)==0 and ffs(1)==1.public static final int ffs(long v)
ffs(0)==0 and ffs(1)==1.public static final int fls(int v)
fls(0)==0 and fls(1)==1.public static final int fls(long v)
fls(0)==0 and fls(1)==1.public static final int log2c(int v)
public static final int zerocount(int v)
public static final int zerocount(long v)
public static final int popcount(int v)
public static final int popcount(long v)
public static final long gcd(long u,
long v)
public static final int gcd(int u,
int v)
Copyright (c) 2006 C. Scott Ananian