javar.util
Class NumberUtil

java.lang.Object
  |
  +--javar.util.NumberUtil

public final class NumberUtil
extends Object

This will help in converting numbers

Author:
Ben Litchfield

Constructor Summary
NumberUtil()
           
 
Method Summary
static long toSigned(byte value)
          This method will convert the byte to an signed value
static long toSigned(byte left, byte right)
          This method will convert the two byte to an unsigned value
static long toSigned(byte one, byte two, byte three, byte four)
          This method will convert the two byte to an unsigned value
static byte[] toSignedByteBytes(long value)
          This will take a signed byte value and convert it to a byte array with one byte.
static byte[] toSignedIntegerBytes(long value)
          This will take a signed int value and convert it to a byte array with four bytes.
static byte[] toSignedShortBytes(long value)
          This will take a signed short value and convert it to a byte array with two bytes.
static long toUnsigned(byte value)
          This method will convert the byte to an unsigned value
static long toUnsigned(byte left, byte right)
          This method will convert the two byte to an unsigned value
static byte[] toUnsignedByteBytes(long value)
          This will take an unsigned byte value and convert it to a byte array with one byte
static byte[] toUnsignedIntegerBytes(long value)
          This will take a signed int value and convert it to a byte array with four bytes.
static byte[] toUnsignedShortBytes(long value)
          This will take an unsigned short value and convert it to a byte array with two bytes
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NumberUtil

public NumberUtil()
Method Detail

toUnsigned

public static final long toUnsigned(byte value)
This method will convert the byte to an unsigned value

Parameters:
value - The most significant bytes
Returns:
An equivalent unsigned value for 8 bits

toSigned

public static final long toSigned(byte value)
This method will convert the byte to an signed value

Parameters:
value - The most significant bytes
Returns:
An equivalent signed value for 8 bits

toUnsigned

public static final long toUnsigned(byte left,
                                    byte right)
This method will convert the two byte to an unsigned value

Parameters:
left - The most significant bytes
right - The least significant bytes
Returns:
An equivalent unsigned value for 16 bits

toSigned

public static final long toSigned(byte left,
                                  byte right)
This method will convert the two byte to an unsigned value

Parameters:
left - The most significant bytes
right - The least significant bytes
Returns:
An equivalent unsigned value for 16 bits

toSigned

public static final long toSigned(byte one,
                                  byte two,
                                  byte three,
                                  byte four)
This method will convert the two byte to an unsigned value

Returns:
An equivalent unsigned value for 16 bits

toUnsignedByteBytes

public static final byte[] toUnsignedByteBytes(long value)
This will take an unsigned byte value and convert it to a byte array with one byte

Parameters:
value - an unsigned byte value
Returns:
An array with the one short byte in it

toSignedByteBytes

public static final byte[] toSignedByteBytes(long value)
This will take a signed byte value and convert it to a byte array with one byte.

Parameters:
value - an signed byte value
Returns:
An array with the one bytes in it

toUnsignedShortBytes

public static final byte[] toUnsignedShortBytes(long value)
This will take an unsigned short value and convert it to a byte array with two bytes

Parameters:
value - an unsigned short value
Returns:
An array with the two short bytes in it

toSignedShortBytes

public static final byte[] toSignedShortBytes(long value)
This will take a signed short value and convert it to a byte array with two bytes.

Parameters:
value - an signed short value
Returns:
An array with the two short bytes in it

toSignedIntegerBytes

public static final byte[] toSignedIntegerBytes(long value)
This will take a signed int value and convert it to a byte array with four bytes.

Parameters:
value - an signed int value
Returns:
An array with the four bytes in it

toUnsignedIntegerBytes

public static final byte[] toUnsignedIntegerBytes(long value)
This will take a signed int value and convert it to a byte array with four bytes.

Parameters:
value - an signed int value
Returns:
An array with the four bytes in it