Name: sgC58550 Date: 05/15/97
import java.text.*;
import java.lang.*;
class Test {
public static void main( String [] args) {
DecimalFormat df = new decimalformat("########.##");
float x = -999.99f;
System.out.println(x + " " + df.format(x));
}
}
PRODUCES THE FOLLOWING OUTPUT: -999.99 -999.98
(if more fractional chars are allowed you see -999.9899999999)
company - SOEKOR Exploration and Production
======================================================================
- duplicates
-
JDK-4054318 DecimalFormat method format loses precision for doubles
-
- Closed
-