public class PrimitiveConverter extends Object
| Modifier and Type | Method and Description |
|---|---|
static byte[] |
float32ToBytes(float val)
Convert a 32-bit floating point number to a byte array
|
static byte[] |
float64ToBytes(double val)
Convert a 64-bit floating point number to a byte array
|
static byte[] |
int16ToBytes(short val)
Convert a signed 16-bit integer to a byte array
|
static byte[] |
int32ToBytes(int val)
Convert a signed 32-bit integer to a byte array
|
static byte[] |
int64ToBytes(long val)
Convert a signed 64-byte integer to a byte array
|
static float |
toFloat32(byte[] bytes)
Convert a byte array to a 32-bit floating point number
|
static double |
toFloat64(byte[] bytes)
Convert a byte array to a 64-bit floating point number
|
static short |
toInt16(byte[] bytes)
Convert a byte array to a signed 16-bit integer
|
static int |
toInt32(byte[] bytes)
Convert a byte array to a signed 32-bit integer
|
static long |
toInt64(byte[] bytes)
Convert a byte array to a signed 64-bit integer
|
static int |
toUint16(byte[] bytes)
Convert a byte array to an unsigned 16-bit integer (int with range of uint16)
|
static long |
toUint32(byte[] bytes)
Convert a byte array to an unsigned 32-bit integer (long with range of uint32)
|
static byte[] |
uint16ToBytes(int val)
Convert an unsigned 16-bit unsigned integer (int with range of uint16) to a byte array
|
static byte[] |
uint32ToBytes(long val)
Convert an unsigned 32-bit unsigned integer (long with range of uint32) to a byte array
|
public static int toInt32(byte[] bytes)
bytes - The array of length 4, 2, or 1public static short toInt16(byte[] bytes)
bytes - The array of length 2public static byte[] int16ToBytes(short val)
val - The short value (16-byte signed integer)public static byte[] int32ToBytes(int val)
val - The int value (32-byte signed integer)public static long toUint32(byte[] bytes)
bytes - The array of length 4public static byte[] uint32ToBytes(long val)
val - The unsigned 32-bit integer as longpublic static int toUint16(byte[] bytes)
bytes - The array of length 2public static byte[] uint16ToBytes(int val)
val - The unsigned 16-bit integer as intpublic static long toInt64(byte[] bytes)
bytes - The array of length 8public static byte[] int64ToBytes(long val)
val - The long valuepublic static float toFloat32(byte[] bytes)
bytes - The array of length 4public static byte[] float32ToBytes(float val)
val - The float valuepublic static double toFloat64(byte[] bytes)
bytes - The array of length 8 or 4public static byte[] float64ToBytes(double val)
val - The double valueCopyright © 2018. All rights reserved.