I\'d like to use Java\'s DecimalFormat to format doubles like so:
#1 - 100 -> $100 #2 - 100.5 -> $100.50 #3 - 100.41 -> $100.41
Th
printf also works.
Example:
double anyNumber = 100; printf("The value is %4.2f ", anyNumber);
Output:
The value is 100.00
4.2 means force the number to have two digits after the decimal. The 4 controls how many digits to the right of the decimal.