private String printXFormat(final short x){
  String sx=null;
  if (x == Short.MIN_VALUE) {
    sx="8000";
  }
 else   if (x < 0) {
    String t;
    if (x == Short.MIN_VALUE) {
      t="0";
    }
 else {
      t=Integer.toString((~(-x - 1)) ^ Short.MIN_VALUE,16);
      if (t.charAt(0) == 'F' || t.charAt(0) == 'f') {
        t=t.substring(16,32);
      }
    }
switch (t.length()) {
case 1:
      sx="800" + t;
    break;
case 2:
  sx="80" + t;
break;
case 3:
sx='8' + t;
break;
case 4:
switch (t.charAt(0)) {
case '1':
sx='9' + t.substring(1,4);
break;
case '2':
sx='a' + t.substring(1,4);
break;
case '3':
sx='b' + t.substring(1,4);
break;
case '4':
sx='c' + t.substring(1,4);
break;
case '5':
sx='d' + t.substring(1,4);
break;
case '6':
sx='e' + t.substring(1,4);
break;
case '7':
sx='f' + t.substring(1,4);
break;
}
break;
}
}
 else {
sx=Integer.toString(x,16);
}
return printXFormat(sx);
}

private String printXFormat ( final short x ) { String sx = null ; if ( x == Short . MIN_VALUE ) { sx = "8000" ; } else if ( x < 0 ) { String t ; if ( x == Short . MIN_VALUE ) { t = "0" ; } else { t = Integer . toString ( ( ~ ( - x - 1 ) ) ^ Short . MIN_VALUE , 16 ) ; if ( t . charAt ( 0 ) == 'F' || t . charAt ( 0 ) == 'f' ) { t = t . substring ( 16 , 32 ) ; } } switch ( t . length ( ) ) { case 1 : sx = "800" + t ; break ; case 2 : sx = "80" + t ; break ; case 3 : sx = '8' + t ; break ; case 4 : switch ( t . charAt ( 0 ) ) { case '1' : sx = '9' + t . substring ( 1 , 4 ) ; break ; case '2' : sx = 'a' + t . substring ( 1 , 4 ) ; break ; case '3' : sx = 'b' + t . substring ( 1 , 4 ) ; break ; case '4' : sx = 'c' + t . substring ( 1 , 4 ) ; break ; case '5' : sx = 'd' + t . substring ( 1 , 4 ) ; break ; case '6' : sx = 'e' + t . substring ( 1 , 4 ) ; break ; case '7' : sx = 'f' + t . substring ( 1 , 4 ) ; break ; } break ; } } else { sx = Integer . toString ( x , 16 ) ; } return printXFormat ( sx ) ; }
format method for the x conversion character and short argument . for x format , the flag character ' - ' , means that the output should be left justified within the field . the default is to pad with blanks on the left . the ' # ' flag character means to lead with ' 0x ' . the field width is treated as the minimum number of characters to be printed . the default is to add no padding . padding is with blanks by default . the precision , if set , is the minimum number of digits to appear . padding is with leading 0s .
