Java Unsigned Number Create unsigned(int val)

Here you can find the source of unsigned(int val)

Description

Considers the bits of a signed 32-bit integer, and converts it into a long integer as if it were unsigned, i.e.

License

Open Source License

Declaration

public static long unsigned(int val) 

Method Source Code

//package com.java2s;
/*/*from  w w w . ja va  2s . com*/
 * BioAssay Ontology Annotator Tools
 * 
 * (c) 2014-2016 Collaborative Drug Discovery Inc.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License 2.0
 * as published by the Free Software Foundation:
 * 
 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 */

public class Main {
    /**
     * Considers the bits of a signed 32-bit integer, and converts it into a long integer as if it were unsigned, i.e.
     * negative values are converted into results above ~2 billion.
     */
    public static long unsigned(int val) {
        return val >= 0 ? val : ((val & 0x7FFFFFFF) | (1L << 31));
    }
}

Related

  1. unsign(final byte b)
  2. unsigned(byte b)
  3. unsigned(byte data)
  4. unsigned(byte value)
  5. unsigned(int num)
  6. unsigned(short value)
  7. unsigned16(short s)
  8. unsigned32ToBytes(long value)
  9. unsigned32ToInt(byte[] bytes)