Name: dbT83986 Date: 11/14/99
java version "1.2.2"
Classic VM (build JDK-1.2.2-W, green threads, sunwjit)
P.1
[cms2] ~/work/Monarc/investigations/scripts > javac Test.java
[cms2] ~/work/Monarc/investigations/scripts > java Test
P.2
Test.java source code:
import java.text.NumberFormat;
public class Test{
// Main method
public static void main(String args[]) {
Test test=new Test(0);
double x[] = { 6.0,0.0 };
for(int i=0;i<x.length;i++) test.formatNum(x[i]);
System.exit(0);
}
// Test class
public NumberFormat numberFormat;
public int numfracdigits;
public Test(int numfracdigits){
this.numfracdigits = numfracdigits;
numberFormat = NumberFormat.getInstance() ;
numberFormat.setMinimumFractionDigits(this.numfracdigits);
numberFormat.setMaximumFractionDigits(this.numfracdigits);
};
public void formatNum(double num) {
// Uncommenting these lines gives valid result
// numberFormat = NumberFormat.getInstance();
// numberFormat.setMinimumFractionDigits(numfracdigits);
// numberFormat.setMaximumFractionDigits(numfracdigits);
String outnum = numberFormat.format(num);
System.out.println("Number:"+num+" Formatted:"+outnum);
}
}
P.3 This is output:
Number:6.0 Formatted:6
Number:0.0 Formatted:1
(Review ID: 97829)
======================================================================
- duplicates
-
JDK-4254220 format(0.0) gives "1." if preceeded by format(0.09). (Regression in 1.2.2 final)
-
- Resolved
-