Unsigned Number ...

Unsigned Number is a Java class that helps with the display and manipulation of unsigned numbers. It is installed on your machine when you follow these instructions.

Create a printable version of this web page


UnsignedNumberPkg
Class UnsignedNumber

java.lang.Object
  UnsignedNumberPkg.UnsignedNumber

public class UnsignedNumber
extends java.lang.Object

Constructor Summary
UnsignedNumber()
           
 
Method Summary
static java.lang.String ByteArrayToAsciiRow(byte[] array, int start, int row_length, java.lang.String separator)
           
static java.lang.String ByteArrayToDecimalRow(byte[] array, int start, int row_length, java.lang.String separator)
           
static java.lang.String ByteArrayToHexRow(byte[] array, int start, int row_length, java.lang.String separator)
           
static long ByteArrayToLong(java.lang.String endian, byte[] byte_array)
           
static java.lang.String ByteToAsciiString(byte byte_value)
           
static java.lang.String ByteToHexString(byte byte_number)
           
static byte HexStringToByte(java.lang.String unsigned_number_string)
           
static int HexStringToInt(java.lang.String unsigned_number_string)
           
static long HexStringToLong(java.lang.String unsigned_number_string)
           
static short HexStringToShort(java.lang.String unsigned_number_string)
           
static java.lang.String IntArrayToDecimalRow(int[] array, int start, int row_length, java.lang.String separator)
           
static java.lang.String IntArrayToHexRow(int[] array, int start, int row_length, java.lang.String separator)
           
static java.lang.String IntToHexString(int int_number)
           
static java.lang.String LongArrayToDecimalRow(long[] array, int start, int row_length, java.lang.String separator)
           
static java.lang.String LongArrayToHexRow(long[] array, int start, int row_length, java.lang.String separator)
           
static void LongToByteArray(java.lang.String endian, long value, byte[] byte_array)
           
static java.lang.String LongToHexString(long long_number)
           
static java.lang.String LongToHexString(long long_number, int size)
           
static java.lang.String ShortArrayToDecimalRow(short[] array, int start, int row_length, java.lang.String separator)
           
static java.lang.String ShortArrayToHexRow(short[] array, int start, int row_length, java.lang.String separator)
           
static java.lang.String ShortToHexString(short short_number)
           
static byte StringToByte(java.lang.String unsigned_number_string)
           
static int StringToInt(java.lang.String unsigned_number_string)
           
static long StringToLong(java.lang.String unsigned_number_string)
           
static short StringToShort(java.lang.String unsigned_number_string)
           
static void ZeroFill(boolean fill)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UnsignedNumber

public UnsignedNumber()
Method Detail

ZeroFill

public static void ZeroFill(boolean fill)
  // ZeroFill(<fill:true/false>)
  // 	Tells UnsignedNumber class what to do when converting numbers to strings. If
  //	the number is smaller than the maximum size that a long/int/char can contain
  //		UnsignedNumber.ZeroFill(true); 
  // 			all subsequent <number>To<type>String() methods will fill unused digits with 0
  //			for example : LongToHexString(0x123) = "0000000000000123" 
  //		UnsignedNumber.ZeroFill(false); 
  // 			all subsequent <number>To<type>String() methods will fill unused digits with " "
  //			for example : LongToHexString(0x123) = "123"
GO TO TOP

StringToLong

public static long StringToLong(java.lang.String unsigned_number_string)
                         throws java.lang.NumberFormatException
Throws: java.lang.NumberFormatException
  // StringToLong(<NumericString>) :
  //   Converts numeric string in hex or decimal format into a JAVA long number
  //       long number = UnsignedNumber.StringToLong("0x100"); // number = 0x100 hex
  //       long number = UnsignedNumber.StringToLong("26"); 	// number = 26 decimal
  
GO TO TOP

HexStringToLong

public static long HexStringToLong(java.lang.String unsigned_number_string)
                            throws java.lang.NumberFormatException
Throws: java.lang.NumberFormatException
   // HexStringToLong(<NumericString>) :
   // 	Converts numeric string in hex format into a JAVA long number
   //		long number = UnsignedNumber.StringToLong("0x100"); // number = 0x100 hex
   
GO TO TOP

LongToHexString

public static java.lang.String LongToHexString(long long_number)
   // LongToHexString(<long>) :
   // 	Converts JAVA long value into hex string
   //	String hex_string = UnsignedNumber.LongToHexString(0x100); // hex_string = "100"
GO TO TOP

LongToHexString

public static java.lang.String LongToHexString(long long_number,
                                               int size)
  // LongToHexString(<long>, <size:8/16/32/64>) :
  // 	Converts JAVA long value into hex string containing the number of digits
  //    needed to hold <size> ie 8 = "00", 16 = "0000", 32 = "00000000", ...
  //		UnsignedNumber.ZeroFill(true);
  //		String hex_string = UnsignedNumber.LongToHexString(0x100,16); // hex_string = "0100"
GO TO TOP

LongToByteArray

public static void LongToByteArray(java.lang.String endian,
                                   long value,
                                   byte[] byte_array)
  // LongToByteArray(<endian:"BIG"/"LITTLE">, <long>, <byte_array>) :
  // 	Converts JAVA long value into <endian> ordered array of bytes
  //		byte_array[] = new byte[2];
  //		UnsignedNumber.LongToByteArray("LITTLE", 0x1234, byte_array);
  //			// byte_array[] = {34 12}
  //		UnsignedNumber.LongToByteArray("BIG", 0x1234, byte_array);
  //			// byte_array[] = {12 23}
GO TO TOP

ByteArrayToLong

public static long ByteArrayToLong(java.lang.String endian,
                                   byte[] byte_array)
  // ByteArrayToLong(<endian:"BIG"/"LITTLE">, <byte_array>) :
  // 	Converts an <endian> ordered array of bytes into JAVA long value
  //		bytes_array[] = {0x12,0x34};
  //		value = UnsignedNumber.ByteArrayToLong("LITTLE",byte_array); // value = 0x3412
  //		value = UnsignedNumber.ByteArrayToLong("BIG",byte_array);    // value = 0x1234;
GO TO TOP

LongArrayToHexRow

public static java.lang.String LongArrayToHexRow(long[] array,
                                                 int start,
                                                 int row_length,
                                                 java.lang.String separator)
  // LongArrayToHexRow(<array>,<start>,<RowLength:1-20>,<separator>) :
  // 	Converts an array of longs into a row of hexidecimal numbers, <RowLength> numbers
  //	long, each number separated from the one before it by the <separator> string
  //	starting at the <start> value in the array. This is useful when displaying strings
  //	of numbers
  //		long array[] = {0x12,0x34,0x56, 0x78,0x9a};
  //		String display1 = UnsignedNumber.LongArrayToHexRow(array, 0, 3, " : " );
  //			display1 = "12 : 34 : 56"
  //		String display2 = UnsignedNumber.LongArrayToHexRow(array, 3, 3, " : " );
  //			display2 = "78 : 9a"
GO TO TOP

LongArrayToDecimalRow

public static java.lang.String LongArrayToDecimalRow(long[] array,
                                                     int start,
                                                     int row_length,
                                                     java.lang.String separator)
  // LongArrayToDecimalRow(<array>,<start>,<row_length:1-20>,<separator>) :
  // 	Converts an array of longs into a row of decimal numbers, <row_length> numbers
  //	long, each number separated from the one before it by the <separator> string
  //	starting at the <start> value in the array. This is useful when displaying strings
  //	of numbers
  //		long array[] = {12,34,56, 78,910};
  //		String display1 = UnsignedNumber.LongArrayToHexRow(array, 0, 3, " : " );
  //			display1 = "12 : 34 : 56"
  //		String display2 = UnsignedNumber.LongArrayToHexRow(array, 3, 3, " : " );
  //			display2 = "78 : 910"
GO TO TOP

StringToInt

public static int StringToInt(java.lang.String unsigned_number_string)
                       throws java.lang.NumberFormatException
Throws: java.lang.NumberFormatException
 // StringToInt(<NumericString>) :
 // Converts numeric string in hex or decimal format into a JAVA int number
 //    int number = UnsignedNumber.StringToInt("0x100"); // number = 0x100 hex
 //    int number = UnsignedNumber.StringToInt("26"); 	  // number = 26 decimal

GO TO TOP

HexStringToInt

public static int HexStringToInt(java.lang.String unsigned_number_string)
                          throws java.lang.NumberFormatException
Throws: java.lang.NumberFormatException
  // HexStringToInt(NumericString) :
  // 	Converts numeric string in hex format into a JAVA long number
  //		int number = UnsignedNumber.StringToLong("0x100"); // number = 0x100 hex
GO TO TOP

IntToHexString

public static java.lang.String IntToHexString(int int_number)
  // IntToHexString(<int>) :
  // 	Converts JAVA int value into hex string
  //		String hex_string = UnsignedNumber.IntToHexString(0x100); // hex_string = "100"
GO TO TOP

IntArrayToHexRow

public static java.lang.String IntArrayToHexRow(int[] array,
                                                int start,
                                                int row_length,
                                                java.lang.String separator)
  // IntArrayToHexRow(<array>,<start>,<row_length:1-20>,<separator>) :
  // 	Converts an array of ints into a row of hexidecimal numbers, <row_length> numbers
  //	long, each number separated from the one before it by the <separator> string
  //	starting at the <start> value in the array. This is useful when displaying strings
  //	of numbers
  //		int array[] = {0x12,0x34,0x56, 0x78,0x9a};
  //		String display1 = UnsignedNumber.IntArrayToHexRow(array, 0, 3, " : " );
  //			display1 = "12 : 34 : 56"
  //		String display2 = UnsignedNumber.IntArrayToHexRow(array, 3, 3, " : " );
  //			display2 = "78 : 9a"
GO TO TOP

IntArrayToDecimalRow

public static java.lang.String IntArrayToDecimalRow(int[] array,
                                                    int start,
                                                    int row_length,
                                                    java.lang.String separator)
  // IntArrayToDecimalRow(<array>,<start>,<row_length:1-20>,<separator>) :
  // 	Converts an array of ints into a row of decimal numbers, <row_length> numbers
  //	long, each number separated from the one before it by the <separator> string
  //	starting at the <start> value in the array. This is useful when displaying strings
  //	of numbers
  //		int array[] = {12,34,56, 78,910};
  //		String display1 = UnsignedNumber.IntArrayToHexRow(array, 0, 3, " : " );
  //			display1 = "12 : 34 : 56"
  //		String display2 = UnsignedNumber.IntArrayToHexRow(array, 3, 3, " : " );
  //			display2 = "78 : 910"
GO TO TOP

StringToShort

public static short StringToShort(java.lang.String unsigned_number_string)
                           throws java.lang.NumberFormatException
Throws: java.lang.NumberFormatException
  // StringToShort(<NumericString>) :
  // 	Converts <NumericString> in hex or decimal format into a JAVA short number
  //		short number = UnsignedNumber.StringToShort("0x100"); // number = 0x100 hex
  //		short number = UnsignedNumber.StringToShort("26"); 	  // number = 26 decimal
GO TO TOP

HexStringToShort

public static short HexStringToShort(java.lang.String unsigned_number_string)
                              throws java.lang.NumberFormatException
Throws: java.lang.NumberFormatException
  // HexStringToShort(<NumericString>) :
  // 	Converts <NumericString> in hex format into a JAVA short number
  //		short number = UnsignedNumber.HexStringToShort("100"); // number = 0x100 hex
GO TO TOP

ShortToHexString

public static java.lang.String ShortToHexString(short short_number)
  // ShortToHexString(<short>) :
  // 	Converts JAVA short value into hex string
  //		String hex_string = UnsignedNumber.ShortToHexString(0x100); // hex_string = "100"
GO TO TOP

ShortArrayToHexRow

public static java.lang.String ShortArrayToHexRow(short[] array,
                                                  int start,
                                                  int row_length,
                                                  java.lang.String separator)
  // ShortArrayToHexRow(<array>,<start>,<row_length:1-20>,<separator>) :
  // 	Converts an array of shorts into a row(s) of hexidecimal numbers, <row_length> numbers
  //	long, each number separated from the one before it by the <separator> string
  //	starting at the <start> value in the array. This is useful when displaying strings
  //	of numbers
  //		short array[] = {0x12,0x34,0x56, 0x78,0x9a};
  //		String display1 = UnsignedNumber.IntArrayToHexRow(array, 0, 3, " : " );
  //			display1 = "12 : 34 : 56"
  //		String display2 = UnsignedNumber.IntArrayToHexRow(array, 3, 3, " : " );
  //			display2 = "78 : 9a"
GO TO TOP

ShortArrayToDecimalRow

public static java.lang.String ShortArrayToDecimalRow(short[] array,
                                                      int start,
                                                      int row_length,
                                                      java.lang.String separator)
  // ShortArrayToDecimalRow(<array>,<start>,<row_length:1-20>,<separator>) :
  // 	Converts an array of shorts into a row of decimal numbers, <row_length> numbers
  //	long, each number separated from the one before it by the <separator> string
  //	starting at the <start> value in the array. This is useful when displaying strings
  //	of numbers
  //		short array[] = {12,34,56, 78,910};
  //		String display1 = UnsignedNumber.ShortArrayToHexRow(array, 0, 3, " : " );
  //		display1 = "12 : 34 : 56"
  //		String display2 = UnsignedNumber.ShortArrayToHexRow(array, 3, 3, " : " );
  //		display2 = "78 : 910" 
GO TO TOP

StringToByte

public static byte StringToByte(java.lang.String unsigned_number_string)
                         throws java.lang.NumberFormatException
Throws: java.lang.NumberFormatException
  // StringToByte(<numeric_string>) :
  // 	Converts numeric string in hex or decimal format into a JAVA byte number
  //		byte number = UnsignedNumber.StringToShort("0x10");  // number = 0x10 hex
  //		byte number = UnsignedNumber.StringToShort("26"); 	  // number = 26 decimal
GO TO TOP

HexStringToByte

public static byte HexStringToByte(java.lang.String unsigned_number_string)
                            throws java.lang.NumberFormatException
Throws: java.lang.NumberFormatException
  // HexStringToByte(<numeric_string>) :
  // 	Converts numeric string in hex format into a JAVA byte number
  //		short number = UnsignedNumber.StringToByte("0x10"); // number = 0x10 hex
GO TO TOP

ByteToHexString

public static java.lang.String ByteToHexString(byte byte_number)
  // ByteToHexString(<byte>) :
  // 	Converts JAVA byte value into hex string
  //		String hex_string = UnsignedNumber.ByteToHexString(0x10); // hex_string = "10"
GO TO TOP

ByteToAsciiString

public static java.lang.String ByteToAsciiString(byte byte_value)
  // ByteToAsciiString(<byte>) :
  // 	Converts JAVA byte value into ascii character or "<value_in_hex>" if the
  //	byte is not printable ascii value
  //		String ascii_string = UnsignedNumber.ByteToAsciiString(64); // ascii_string = "A"
  //		String ascii_string = UnsignedNumber.ByteToAsciiString(0);  // ascii_string = "<0>"
GO TO TOP

ByteArrayToAsciiRow

public static java.lang.String ByteArrayToAsciiRow(byte[] array,
                                                   int start,
                                                   int row_length,
                                                   java.lang.String separator)
  // ByteArrayToAsciiRow(<array>,<start>,<row_length:1-20>,<separator>) :
  // 	Converts an array of bytes into a row of ascii letters/digits, <row_length> 
  //	long, each letter/digit separated from the one before it by the <separator> string
  //	starting at the <start> value in the array. This is useful when displaying strings
  //	of ascii values
  //		byte array[] = {64,66,67, 68,1};
  //		String display1 = UnsignedNumber.IntArrayToHexRow(array, 0, 3, " : " );
  //			display1 = "A : B : C"
  //		String display2 = UnsignedNumber.IntArrayToHexRow(array, 3, 3, " : " );
  //			display2 = "D : <1>"
GO TO TOP

ByteArrayToHexRow

public static java.lang.String ByteArrayToHexRow(byte[] array,
                                                 int start,
                                                 int row_length,
                                                 java.lang.String separator)
  // ByteArrayToHexRow(<array>,<start>,<row_length:1-20>,<separator>) :
  // 	Converts an array of bytes into a row of hexidecimal numbers, <row_length> numbers
  //	long, each number separated from the one before it by the <separator> string
  //	starting at the <start> value in the array. This is useful when displaying strings
  //	of numbers
  //		byte array[] = {0x12,0x34,0x56, 0x78,0x9a};
  //		String display1 = UnsignedNumber.ByteArrayToHexRow(array, 0, 3, " : " );
  //		display1 = "12 : 34 : 56"
  //		String display2 = UnsignedNumber.ByteArrayToHexRow(array, 3, 3, " : " );
  //		display2 = "78 : 9a"
GO TO TOP

ByteArrayToDecimalRow

public static java.lang.String ByteArrayToDecimalRow(byte[] array,
                                                     int start,
                                                     int row_length,
                                                     java.lang.String separator)
  // ByteArrayToDecimalRow(<array>,<start>,<row_length:1-20>,<separator>) :
  // 	Converts an array of bytes into a row of decimal numbers, <row_length> numbers
  //	long, each number separated from the one before it by the <separator> string
  //	starting at the <start> value in the array. This is useful when displaying strings
  //	of numbers
  //		byte array[] = {1,2,3,4,5};
  //		String display1 = UnsignedNumber.IntArrayToHexRow(array, 0, 3, " : " );
  //		display1 = "1 : 2 : 3"
  //		String display2 = UnsignedNumber.IntArrayToHexRow(array, 3, 3, " : " );
  //		display2 = "4 : 5"
GO TO TOP