In our case, it is important and necessary to output all floating
point numbers in higer precision with 6 decimal digits. But I noticed
that in ByteBuffer.formatDouble(double, ByteBuffer), a new instance of
DecimalFormat is created at each call of the method which will causes
a great performance loss. Just defining a shared instance of
DecimlaFormat instead as a static field of ByteBuffer, we've got a
double speed up.
Here below is my suggestion on how to modify ByteBuffer:

    private static final DecimalFormat dn = new DecimalFormat("0.######", dfs);

    public static String formatDouble(double d, ByteBuffer buf) {
        if (HIGH_PRECISION) {
            // DecimalFormat dn = new DecimalFormat("0.######", dfs);
            String sform = dn.format(d);
            if (buf == null)
                return sform;
            else {
                buf.append(sform);
                return null;
            }
        }
    ...
    }

------------------------------------------------------------------------------
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.1t3xt.com/docs/book.php

Reply via email to