Here you can find the source of toLong(byte[] n)
Parameter | Description |
---|---|
n | a parameter |
public static long toLong(byte[] n)
//package com.java2s; /*/*from w w w . j av a 2 s .co m*/ * Copyright 05-abr-2014 ?Deme * * This file is part of 'dmLang-8.1.0'. * * 'dmLang-8.1.0' 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. * * 'dmLang-8.1.0' 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 'dmLang-8.1.0'. If not, see <http://www.gnu.org/licenses/>. */ public class Main { /** * Converter * * @param n * @return */ public static long toLong(byte[] n) { long r = 0; long m = 1; for (int i = 0; i < 8; i++) { int b = n[i]; if (b < 0) { b += 256; } r += b * m; m *= 256; } return r; } }