public static String ulong2str ( final long ulongValue , final int radix , final char [ ] charBuffer ) { if ( radix < 2 || radix > 36 ) { throw new IllegalArgumentException ( "Illegal radix [" + radix + ' ' ) ; } if ( ulongValue == 0 ) { return "0" ; } else { final String result ; if ( ulongValue > 0 ) { result = Long . toString ( ulongValue , radix ) . toUpperCase ( Locale . ENGLISH ) ; } else { final char [ ] buffer = charBuffer == null || charBuffer . length < 64 ? new char [ 64 ] : charBuffer ; int pos = buffer . length ; long topPart = ulongValue >>> 32 ; long bottomPart = ( ulongValue & 0xFFFFFFFF L ) + ( ( topPart % radix ) << 32 ) ; topPart /= radix ; while ( ( bottomPart | topPart ) > 0 ) { final int val = ( int ) ( bottomPart % radix ) ; buffer [ -- pos ] = ( char ) ( val < 10 ? ' ' + val : ' ' + val - 10 ) ; bottomPart = ( bottomPart / radix ) + ( ( topPart % radix ) << 32 ) ; topPart /= radix ; } result = new String ( buffer , pos , buffer . length - pos ) ; } return result ; } }
Convert unsigned long value into string representation with defined radix base .