Is String.format% d always compatible with BigInteger?

With String.format % d and its variants, we can easily format primitive integers and long ones. However, do these formatting options work fine with BigInteger?

I did some tests and they seem to work well, for example:

public class Test6 {
    public static void main(final String args[]) {
        final java.math.BigInteger b = java.math.BigInteger.TEN.pow(999999);
        System.out.println(String.format("%,d", b));
    }
}

But are there any problems to keep track of?

+4
source share
1 answer

The documentation for format strings has an extensive section .

I believe that the only difficult part may be local sensitivity (for example, what decimal point to use), but this also applies to other numerical types.

BigInteger .

'd'

, . .

'#' , FormatFlagsConversionMismatchException.

+6

All Articles