net.cscott.jutil
public abstract class Util extends Object
Version: $Id: Util.java,v 1.1 2003/03/20 01:58:20 cananian Exp $
Method Summary | |
---|---|
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 long | gcd(long u, long v) Returns the greatest common divisor of a pair of numbers. |
static int | gcd(int u, int 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 String | repeatString(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. |
Returns: the first bit set in the argument.
ffs(0)==0
and ffs(1)==1
.
Returns: the first bit set in the argument.
ffs(0)==0
and ffs(1)==1
.
Returns: the last bit set in the argument.
fls(0)==0
and fls(1)==1
.
Returns: the last bit set in the argument.
fls(0)==0
and fls(1)==1
.
Returns: a string consisting of s
repeated n
times.