go to previous page   go to home page   go to next page highlighting

Answer:

The international standard is to use space to separate groups of three digits.


Floating Point Formatting

import java.text.*;

public class IODemoFloat
{
  public static void main ( String[] args )
  {
    double value = 12345.6789 ;    
    DecimalFormat numform = new DecimalFormat(); 
    System.out.println( "value = " + numform.format(value) );
  }
}

The default locale also determines how DecimalFormat.format() formats a floating point number. Here is a program that shows this. The output (on my computer in the US) is:

value = 12,345.679

In Germany the program would output:

value = 12.345,679

In France the program would output:

value = 12 345,679

The international standard is to use either dot or comma to separate the integer part from the fractional part, and not use them in the integer part of a number.

The output value has been rounded to three places to the right of the decimal point. You can control how many places are used for the fractional part. This is discussed in a few pages.


QUESTION 3:

Has the variable value been changed by format()?


go to previous page   go to home page   go to next page