/** * Format the absolute value of the imaginary part. * * @param absIm Absolute value of the imaginary part of a complex number. * @param toAppendTo where the text is to be appended. * @param pos On input: an alignment field, if desired. On output: the * offsets of the alignment field. * @return the value passed in as toAppendTo. */ private StringBuffer formatImaginary(double absIm, StringBuffer toAppendTo, FieldPosition pos) { pos.setBeginIndex(0); pos.setEndIndex(0); CompositeFormat.formatDouble(absIm, getImaginaryFormat(), toAppendTo, pos); if (toAppendTo.toString().equals("1")) { // Remove the character "1" if it is the only one. toAppendTo.setLength(0); } return toAppendTo; }
/** * Format the absolute value of the imaginary part. * * @param absIm Absolute value of the imaginary part of a complex number. * @param toAppendTo where the text is to be appended. * @param pos On input: an alignment field, if desired. On output: the * offsets of the alignment field. * @return the value passed in as toAppendTo. */ private StringBuffer formatImaginary(double absIm, StringBuffer toAppendTo, FieldPosition pos) { pos.setBeginIndex(0); pos.setEndIndex(0); CompositeFormat.formatDouble(absIm, getImaginaryFormat(), toAppendTo, pos); if (toAppendTo.toString().equals("1")) { // Remove the character "1" if it is the only one. toAppendTo.setLength(0); } return toAppendTo; }