Here you can find the source of unsignedIntToLong(byte[] b)
Parameter | Description |
---|---|
b | an array of 4 unsigned bytes |
public static long unsignedIntToLong(byte[] b)
//package com.java2s; /* Penny Post - A postage system for email * Copyright (c) 2006-2007 Gregory Rubin <grrubin@gmail.com> * http://www.nettgryppa.com // w ww .j a v a 2 s. c om * Copyright (C) 2007 Aliasgar Lokhandwala <d7@freepgs.com> * http://pennypost.sourceforge.net/ * * CashUtils.java: Provides common helper methods * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * 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 General Public License for more details. * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ public class Main { /** * Converts a 4 byte array of unsigned bytes to an long * * @param b * an array of 4 unsigned bytes * @return a long representing the unsigned int * * @author Gregory Rubin */ public static long unsignedIntToLong(byte[] b) { long l = 0; l |= b[0] & 0xFF; l <<= 8; l |= b[1] & 0xFF; l <<= 8; l |= b[2] & 0xFF; l <<= 8; l |= b[3] & 0xFF; return l; } }