|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectorg.mbari.util.NumberUtil
public class NumberUtil
Useful static methods for manipulating numbers.
| Method Summary | |
|---|---|
static byte[] |
toByteArray(char c)
Converts an char to the corresponding byte[] array. |
static byte[] |
toByteArray(char c,
boolean isReverseOrder)
Description of the Method |
static byte[] |
toByteArray(double d)
Converts a double to the corresponding byte[] array. |
static byte[] |
toByteArray(double d,
boolean isReverseOrder)
Converts a double to the corresponding byte[] array |
static byte[] |
toByteArray(float f)
Converts a float to the corresponding byte[] array. |
static byte[] |
toByteArray(float f,
boolean isReverseOrder)
Converts a float to the corresponding byte[] array |
static byte[] |
toByteArray(int i)
Converts an integer to the corresponding byte[] array. |
static byte[] |
toByteArray(int i,
boolean isReverseOrder)
Converts an integer to the corresponding byte[] array |
static byte[] |
toByteArray(long l)
Converts a long to the corresponding byte[] array. |
static byte[] |
toByteArray(long l,
boolean isReverseOrder)
Converts a long to the corresponding byte[] array |
static byte[] |
toByteArray(short i)
Converts a short to the corresponding byte[] array. |
static byte[] |
toByteArray(short i,
boolean isReverseOrder)
Converts a short to the corresponding byte[] array |
static char |
toChar(byte[] si)
Convert a byte[] (most significant byte first) to the corresponding char value. |
static char |
toChar(byte[] si,
boolean isReverseOrder)
Convert a byte[] to the corresponding char value. |
static double |
toDouble(byte[] si)
Convert a byte[] (most significant byte first) to the corresponding double value. |
static double |
toDouble(byte[] si,
boolean isReverseOrder)
Convert a byte[] to the corresponding double value. |
static float |
toFloat(byte[] si)
Convert a byte[] (most significant byte first) to the corresponding float value. |
static float |
toFloat(byte[] si,
boolean isReverseOrder)
Convert a byte[] to the corresponding float value. |
static java.lang.String |
toHexString(byte[] b)
Format a byte array as a hexadecimal string. |
static int |
toInt(byte[] si)
Convert a byte[] (most significant byte first) to the corresponding int value. |
static int |
toInt(byte[] si,
boolean isReverseOrder)
Convert a byte[] to the corresponding int value. |
static long |
toLong(byte[] si)
Convert a byte[] (most significant byte first) to the corresponding long value. |
static long |
toLong(byte[] si,
boolean isReverseOrder)
Convert a byte[] to the corresponding long value. |
static short |
toShort(byte[] si)
Convert a byte[] (most significant byte first) to the corresponding short value. |
static short |
toShort(byte[] si,
boolean isReverseOrder)
Convert a byte[] to the corresponding short value. |
static int |
toUnsignedInt(byte b)
Convert an unsigned byte to an integer |
static int |
toUnsignedInt(byte lsb,
byte msb)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static final byte[] toByteArray(char c)
c - char input
public static final byte[] toByteArray(double d)
d - Integer input
public static final byte[] toByteArray(float f)
f - float input
public static final byte[] toByteArray(int i)
i - Integer input
public static final byte[] toByteArray(long l)
l - long input
public static final byte[] toByteArray(short i)
i - Integer input
public static final byte[] toByteArray(char c,
boolean isReverseOrder)
c - Description of the ParameterisReverseOrder - Description of the Parameter
public static final byte[] toByteArray(double d,
boolean isReverseOrder)
isReverseOrder - True if the ordering is least significant byte to
most signifigant byte, false for most significant to least.d - Description of the Parameter
public static final byte[] toByteArray(float f,
boolean isReverseOrder)
f - Short inputisReverseOrder - True if the ordering is least significant byte to
most signifigant byte, false for most significant to least.
public static final byte[] toByteArray(int i,
boolean isReverseOrder)
i - Integer inputisReverseOrder - True if the ordering is least significant byte to
most signifigant byte, false for most significant to least.
public static final byte[] toByteArray(long l,
boolean isReverseOrder)
isReverseOrder - True if the ordering is least significant byte to
most signifigant byte, false for most significant to least.l - Description of the Parameter
public static final byte[] toByteArray(short i,
boolean isReverseOrder)
i - Short inputisReverseOrder - True if the ordering is least significant byte to
most signifigant byte, false for most significant to least.
public static final char toChar(byte[] si)
si - the input array
public static final char toChar(byte[] si,
boolean isReverseOrder)
si - the input arrayisReverseOrder - True if little-endian. False if big-endian (Most significant byte first)
public static final double toDouble(byte[] si)
si - the input array
public static final double toDouble(byte[] si,
boolean isReverseOrder)
si - the input arrayisReverseOrder - True if little-endian. False if big-endian (Most significant byte first)
public static final float toFloat(byte[] si)
si - the input array
public static final float toFloat(byte[] si,
boolean isReverseOrder)
si - the input arrayisReverseOrder - True if little-endian. False if big-endian (Most significant byte first)
public static final int toInt(byte[] si)
si - the input array
public static final int toInt(byte[] si,
boolean isReverseOrder)
si - the input arrayisReverseOrder - True if little-endian. False if big-endian (Most significant byte first)
public static final long toLong(byte[] si)
si - the input array
public static final long toLong(byte[] si,
boolean isReverseOrder)
si - the input arrayisReverseOrder - True if little-endian. False if big-endian (Most significant byte first)
public static final short toShort(byte[] si)
si - the input array
public static final short toShort(byte[] si,
boolean isReverseOrder)
si - the input arrayisReverseOrder - True if little-endian. False if big-endian (Most significant byte first)
public static int toUnsignedInt(byte b)
b - byte to convert
public static int toUnsignedInt(byte lsb,
byte msb)
lsb - The least significant bytemsb - The most significant byte
public static java.lang.String toHexString(byte[] b)
byte[] bytes = new byte[]{(byte)0x12, (byte)0x0F, (byte)0xF0};
String hex = NumberUtil.toHexString(bytes); // 120ff0
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||