Java Long to Int long2int(final long l)

Here you can find the source of long2int(final long l)

Description

Returns the int value that is closest to l.

License

Open Source License

Declaration

public static int long2int(final long l) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    /**/* w  w  w . j a v  a2s  .co  m*/
     * Returns the int value that is closest to l. That is, if l can fit into a 32-bit unsigned
     * number, returns (int)l. Otherwise, returns either Integer.MAX_VALUE or Integer.MIN_VALUE as
     * appropriate.
     */
    public static int long2int(final long l) {
        int m;
        if (l < (m = Integer.MAX_VALUE) && l > (m = Integer.MIN_VALUE))
            return (int) l;
        return m;
    }
}

Related

  1. long2int(final long l)
  2. long2int(final long l)
  3. long2Int(final long v)
  4. long2int(final long[] a)
  5. Long2Int(long i)
  6. long2int(Long source)