Java Byte to Unsigned Int byteToUnsignedInt(byte b)

Here you can find the source of byteToUnsignedInt(byte b)

Description

Convert a byte into an unsigned integer.

License

Open Source License

Parameter

Parameter Description
b the <code>byte</code> to cast

Return

a postiive int whose lowest byte contains the bits of b.

Declaration

public static final int byteToUnsignedInt(byte b) 

Method Source Code

//package com.java2s;
/*// ww w  .  j  av  a  2  s. c  om
 * JGrass - Free Open Source Java GIS http://www.jgrass.org 
 * (C) HydroloGIS - www.hydrologis.com 
 * 
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Library General Public License as published by the Free
 * Software Foundation; either version 2 of the License, or (at your option) any
 * later version.
 * 
 * This library 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 Library General Public License for more
 * details.
 * 
 * You should have received a copy of the GNU Library General Public License
 * along with this library; if not, write to the Free Foundation, Inc., 59
 * Temple Place, Suite 330, Boston, MA 02111-1307 USA
 */

public class Main {
    /**
     * Convert a <code>byte</code> into an unsigned integer.
     *
     * @param b the <code>byte</code> to cast
     *
     * @return a postiive <code>int</code> whose lowest byte contains the bits
     *          of <code>b</code>.
     */
    public static final int byteToUnsignedInt(byte b) {
        return ((int) b) & 0xff;
    }
}

Related

  1. byteToUnInt(Byte sByte)
  2. byteToUnsigned(byte b)
  3. byteToUnsigned(byte b)
  4. byteToUnsigned(byte signed)
  5. byteToUnsignedByte(byte b)
  6. byteToUnsignedint(byte b)
  7. byteToUnsignedInt(final byte b)
  8. byteToUnsignedLong(byte data)