static public byte[] asByteArray(long inValue) {

        long value = inValue;
        // check for 0
        if (0 == value) {
            return ZERO_BYTEARRAY;
        }

        // make space for the largest long number
        byte[] bytes = new byte[SIZE_MAXLONG];
        // check for negative ints
        boolean bNegative = false;
        if (0 > value) {
            // force it positive for parsing
            bNegative = true;
            value = -value;
        }
        // now loop back through each digit in the long
        int index = SIZE_MAXLONG - 1;
        for (; 0 <= index && 0 != value; index--) {
            bytes[index] = HEX_BYTES[(int) (value % 10)];
            value /= 10;
        }

        // length is how ever many digits there were + a possible negative sign
        int len = (SIZE_MAXLONG - 1 - index);
        if (bNegative) {
            len++;
        }

        // now copy out the "real bytes" for returning
        byte[] realBytes = new byte[len];
        for (int i = len - 1, x = SIZE_MAXLONG - 1; 0 <= i; i--, x--) {
            realBytes[i] = bytes[x];
        }
        // add negative sign if we need to
        if (bNegative) {
            realBytes[0] = DASH;
        }
        return realBytes;
    }
static public byte [ ] asByteArray ( long inValue ) { long value = inValue ; if ( 0 == value ) { return ZERO_BYTEARRAY ; } byte [ ] bytes = new byte [ SIZE_MAXLONG ] ; boolean bNegative = false ; if ( 0 > value ) { bNegative = true ; value = - value ; } int index = SIZE_MAXLONG - 1 ; for ( ; 0 <= index && 0 != value ; index -- ) { bytes [ index ] = HEX_BYTES [ ( int ) ( value % 10 ) ] ; value /= 10 ; } int len = ( SIZE_MAXLONG - 1 - index ) ; if ( bNegative ) { len ++ ; } byte [ ] realBytes = new byte [ len ] ; for ( int i = len - 1 , x = SIZE_MAXLONG - 1 ; 0 <= i ; i -- , x -- ) { realBytes [ i ] = bytes [ x ] ; } if ( bNegative ) { realBytes [ 0 ] = DASH ; } return realBytes ; }
Utility method to convert a long (positive or negative) into the
byte[] representation. So "50" would return a byte[2] of "50", "-100"
would return a byte[3] of "-100".

@param inValue
@return byte[]