Here you can find the source of bytes2int(byte value1, byte value2)
Parameter | Description |
---|---|
value1 | here 05 |
value2 | here 01 |
public static int bytes2int(byte value1, byte value2)
//package com.java2s; //License from project: Open Source License public class Main { /**// w w w . j a v a2s . c o m * Example, hex code: 05 01 * @param value1 here 05 * @param value2 here 01 * @return 01 * 256 + 05 */ public static int bytes2int(byte value1, byte value2) { return (byte2int(value1) + byte2int(value2) * 256); } /** * Example, hex code: 05 03 00 01 * @param value1 here 05 * @param value2 here 03 * @param value3 here 00 * @param value4 here 01 * @return (03 * 256 + 05) + (01 * 256 + 00) * 65536 */ public static int bytes2int(byte value1, byte value2, byte value3, byte value4) { return (bytes2int(value1, value2) + bytes2int(value3, value4) * 65536); } public static int byte2int(byte value) { if (value < 0) { return (int) (256 + value); } else { return (int) value; } } }