tribble.text
Class Hex

java.lang.Object
  extended bytribble.text.Hex

public class Hex
extends java.lang.Object

Hexadecimal character conversion methods.

Since:
2001-11-12
Version:
$Revision: 1.2 $ $Date: 2003/02/09 16:27:35 $
Author:
David R. Tribble, david@tribble.com
Copyright ©2001 by David R. Tribble, all rights reserved.
Permission is granted to freely use and distribute this source code provided that the original copyright and authorship notices remain intact.

Field Summary
static byte[] DIGIT_VALUE
          Hexadecimal digit values (indexed by a hexadecimal digit character).
static char[] HEX_DIGIT
          Hexadecimal digit characters.
 
Method Summary
static java.lang.String toHex(int val, int n)
          Convert an unsigned binary integer value into an n-digit hexadecimal digit string.
static java.lang.String toHex(long val, int n)
          Convert an unsigned binary integer value into an n-digit hexadecimal digit string.
static java.lang.String toHex16(long val)
          Convert an unsigned long binary integer value into a 16-digit hexadecimal digit string.
static java.lang.String toHex2(int val)
          Convert an unsigned binary integer value into a 2-digit hexadecimal digit string.
static java.lang.String toHex4(int val)
          Convert an unsigned binary integer value into a 4-digit hexadecimal digit string.
static java.lang.String toHex8(int val)
          Convert an unsigned binary integer value into an 8-digit hexadecimal digit string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

HEX_DIGIT

public static final char[] HEX_DIGIT
Hexadecimal digit characters.


DIGIT_VALUE

public static final byte[] DIGIT_VALUE
Hexadecimal digit values (indexed by a hexadecimal digit character).

Method Detail

toHex

public static java.lang.String toHex(long val,
                                     int n)
Convert an unsigned binary integer value into an n-digit hexadecimal digit string.

Parameters:
val - An unsigned binary integer value.
n - The number of hexadecimal digits to place into the resulting digit string.
Returns:
A hexadecimal digit character string having n digits.
Since:
1.1, 2001-11-12

toHex

public static java.lang.String toHex(int val,
                                     int n)
Convert an unsigned binary integer value into an n-digit hexadecimal digit string.

Parameters:
val - An unsigned binary integer value.
n - The number of hexadecimal digits to place into the resulting digit string.
Returns:
A hexadecimal digit character string having n digits.
Since:
1.1, 2001-11-12

toHex2

public static java.lang.String toHex2(int val)
Convert an unsigned binary integer value into a 2-digit hexadecimal digit string.

Parameters:
val - An unsigned binary integer value.
Returns:
A 2-character hexadecimal string.
Since:
1.1, 2001-11-12

toHex4

public static java.lang.String toHex4(int val)
Convert an unsigned binary integer value into a 4-digit hexadecimal digit string.

Parameters:
val - An unsigned binary integer value.
Returns:
A 4-character hexadecimal string.
Since:
1.1, 2001-11-12

toHex8

public static java.lang.String toHex8(int val)
Convert an unsigned binary integer value into an 8-digit hexadecimal digit string.

Parameters:
val - An unsigned binary integer value.
Returns:
An 8-character hexadecimal string.
Since:
1.1, 2001-11-12

toHex16

public static java.lang.String toHex16(long val)
Convert an unsigned long binary integer value into a 16-digit hexadecimal digit string.

Parameters:
val - An unsigned binary integer value.
Returns:
A 16-character hexadecimal string.
Since:
1.1, 2001-11-12