Java Reference
In-Depth Information
The following snippet of code shows some more examples of
'o'
and
'x'
conversions for
int
and
BigInteger
argument types:
System.out.printf("%o %n", 1969);
System.out.printf("%o %n", -1969);
System.out.printf("%o %n", new BigInteger("1969"));
System.out.printf("%o %n", new BigInteger("-1969"));
System.out.printf("%x %n", 1969);
System.out.printf("%x %n", -1969);
System.out.printf("%x %n", new BigInteger("1969"));
System.out.printf("%x %n", new BigInteger("-1969"));
System.out.printf("%#o %n", 1969);
System.out.printf("%#x %n", 1969);
System.out.printf("%#o %n", new BigInteger("1969"));
System.out.printf("%#x %n", new BigInteger("1969"));
3661
37777774117
3661
-3661
7b1
fffff84f
7b1
-7b1
03661
0x7b1
03661
0x7b1
Floating-Point Number Formatting
Floating-point number formatting deals with formatting numbers, which have a whole part and a fraction part. It can
be applied to format values of
float
,
Float
,
double
,
Double
, and
BigDecimal
data types. Table
13-6
contains the list of
conversions used for formatting floating-point number formatting.