Java Utililty Methods Long to Int

List of utility methods to do Long to Int

Description

The list of methods to do Long to Int are organized into topic(s).

Method

intlong2int(final long l)
Returns the hash code that would be returned by Long#hashCode() .
return (int) (l ^ (l >>> 32));
intlong2int(final long l)
longint
return (int) (l ^ (l >>> 32));
intlong2int(final long l)
Returns the int value that is closest to l.
int m;
if (l < (m = Integer.MAX_VALUE) && l > (m = Integer.MIN_VALUE))
    return (int) l;
return m;
intlong2Int(final long v)
long Int
if (MAX_INT_VALUE < v) {
    throw new IllegalArgumentException(
            "Read uint32 value " + toHexString(v) + " > int32-max " + toHexString(MAX_INT_VALUE));
return (int) v;
int[]long2int(final long[] a)
longint
final int[] i = new int[a.length];
for (int d = 0; d < a.length; ++d)
    i[d] = (int) a[d];
return i;
intLong2Int(long i)
Long Int
int o;
try {
    o = new Long(i).intValue();
} catch (Exception e) {
    o = 0;
return o;
Integerlong2int(Long source)
Converts a long to an integer, for comparison purposes.
return source > Integer.MAX_VALUE ? Integer.MAX_VALUE
        : source < Integer.MIN_VALUE ? Integer.MIN_VALUE : Integer.valueOf(source.toString());
intlongToInt(final Long l, final String name, final int deflt)
long To Int
if (l == null) {
    return deflt;
if (l > Integer.MAX_VALUE) {
    throw new IllegalArgumentException(name + " can be no greater than " + Integer.MAX_VALUE);
return new Long(l).intValue();
intlongToInt(long d)
long To Int
int lo = 0;
try {
    lo = Integer.parseInt(String.valueOf(d));
} catch (Exception e) {
    lo = 0;
return lo;
intlongToInt(long l)
long To Int
if (l < Integer.MIN_VALUE || l > Integer.MAX_VALUE) {
    throw new IllegalArgumentException(l + " cannot be cast to int");
return (int) l;