Here you can find the source of byteToUnsignedInt(byte b)
byte
into an unsigned integer.
Parameter | Description |
---|---|
b | the <code>byte</code> to cast |
int
whose lowest byte contains the bits of b
.
public static final int byteToUnsignedInt(byte b)
//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; } }