public static void decodeToString(byte[] from,int location,int precision,int scale,AkibanAppender appender){
  final int intCount=precision - scale;
  final int intFull=intCount / DECIMAL_DIGIT_PER;
  final int intPartial=intCount % DECIMAL_DIGIT_PER;
  final int fracFull=scale / DECIMAL_DIGIT_PER;
  final int fracPartial=scale % DECIMAL_DIGIT_PER;
  int curOff=location;
  final int mask=(from[curOff] & 0x80) != 0 ? 0 : -1;
  from[curOff]^=0x80;
  if (mask != 0)   appender.append('-');
  boolean hadOutput=false;
  if (intPartial != 0) {
    int count=DECIMAL_BYTE_DIGITS[intPartial];
    int x=unpackIntegerByWidth(count,from,curOff) ^ mask;
    curOff+=count;
    if (x != 0) {
      hadOutput=true;
      appender.append(x);
    }
  }
  for (int i=0; i < intFull; ++i) {
    int x=unpackIntegerByWidth(DECIMAL_TYPE_SIZE,from,curOff) ^ mask;
    curOff+=DECIMAL_TYPE_SIZE;
    if (hadOutput) {
      appender.append(String.format("%09d",x));
    }
 else     if (x != 0) {
      hadOutput=true;
      appender.append(x);
    }
  }
  if (fracFull + fracPartial > 0) {
    if (hadOutput) {
      appender.append('.');
    }
 else {
      appender.append("0.");
    }
  }
 else   if (!hadOutput)   appender.append('0');
  for (int i=0; i < fracFull; ++i) {
    int x=unpackIntegerByWidth(DECIMAL_TYPE_SIZE,from,curOff) ^ mask;
    curOff+=DECIMAL_TYPE_SIZE;
    appender.append(String.format("%09d",x));
  }
  if (fracPartial != 0) {
    int count=DECIMAL_BYTE_DIGITS[fracPartial];
    int x=unpackIntegerByWidth(count,from,curOff) ^ mask;
    int width=scale - (fracFull * DECIMAL_DIGIT_PER);
    appender.append(String.format("%0" + width + "d",x));
  }
  from[location]^=0x80;
}

public static void decodeToString ( byte [ ] from , int location , int precision , int scale , AkibanAppender appender ) { final int intCount = precision - scale ; final int intFull = intCount / DECIMAL_DIGIT_PER ; final int intPartial = intCount % DECIMAL_DIGIT_PER ; final int fracFull = scale / DECIMAL_DIGIT_PER ; final int fracPartial = scale % DECIMAL_DIGIT_PER ; int curOff = location ; final int mask = ( from [ curOff ] & 0x80 ) != 0 ? 0 : - 1 ; from [ curOff ] ^= 0x80 ; if ( mask != 0 ) appender . append ( '-' ) ; boolean hadOutput = false ; if ( intPartial != 0 ) { int count = DECIMAL_BYTE_DIGITS [ intPartial ] ; int x = unpackIntegerByWidth ( count , from , curOff ) ^ mask ; curOff += count ; if ( x != 0 ) { hadOutput = true ; appender . append ( x ) ; } } for ( int i = 0 ; i < intFull ; ++ i ) { int x = unpackIntegerByWidth ( DECIMAL_TYPE_SIZE , from , curOff ) ^ mask ; curOff += DECIMAL_TYPE_SIZE ; if ( hadOutput ) { appender . append ( String . format ( "%09d" , x ) ) ; } else if ( x != 0 ) { hadOutput = true ; appender . append ( x ) ; } } if ( fracFull + fracPartial > 0 ) { if ( hadOutput ) { appender . append ( '.' ) ; } else { appender . append ( "0." ) ; } } else if ( ! hadOutput ) appender . append ( '0' ) ; for ( int i = 0 ; i < fracFull ; ++ i ) { int x = unpackIntegerByWidth ( DECIMAL_TYPE_SIZE , from , curOff ) ^ mask ; curOff += DECIMAL_TYPE_SIZE ; appender . append ( String . format ( "%09d" , x ) ) ; } if ( fracPartial != 0 ) { int count = DECIMAL_BYTE_DIGITS [ fracPartial ] ; int x = unpackIntegerByWidth ( count , from , curOff ) ^ mask ; int width = scale - ( fracFull * DECIMAL_DIGIT_PER ) ; appender . append ( String . format ( "%0" + width + "d" , x ) ) ; } from [ location ] ^= 0x80 ; }
decodes bytes representing the decimal value into the given akibanappender .
