Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: formatting

...

Code Block
bgColor#FFcccc
double dollar = 1.00;
double dime = 0.10;
int number = 7;
System.out.println(
  "A dollar less " + number + " dimes is $" +
                   (dollar - number * dime)  
);

Because the value 0.10 lacks an exact representation in either Java floating-point type (or any floating-point format that uses a binary mantissa), on most platforms, this program prints:

...

Code Block
bgColor#ccccff
int dollar = 100;
int dime = 10;
int number = 7;
System.out.println(
 ( "A dollar less " + number + " dimes is " +
		    (dollar - number * dime) + " cents"  
);

This code correctly outputs:

...