FULL PRODUCT VERSION :
1.4.2_11, 1.5.0_06, 6.0_80
ADDITIONAL OS VERSION INFORMATION :
Windows 2000
Windows XP
Solaries
Linux
EXTRA RELEVANT SYSTEM CONFIGURATION :
JRE 1.2
under solaries jre platform in Websphere Application server 5.0
Windows 2000 workstation.
WAS 5.0/jdk 1.3 under Unix boxes.
A DESCRIPTION OF THE PROBLEM :
When I submit the values :
Input : 16.15,3
output: 16149
public static String doubleToStringForMQ(double p_val, int p_digits)
{
String str;
str = new Integer(new Double(p_val * java.lang.Math.pow(10, p_digits)).intValue()).toString();
System.out.println(str);
return str;
}
its happening for only this input, well atleast to my knowledge...
for instance if input : 16.13 o/p: 1613
if one calculates for input 16.15 o/p should be 1615 not 16149
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Call this method from any from any class:
public static String doubleToStringForMQ(double p_val, int p_digits)
{
String str;
str = new Integer(new Double(p_val * java.lang.Math.pow(10, p_digits)).intValue()).toString();
System.out.println(str);
return str;
}
2. call the above method with the following parameters:
doubleToStringForMQ(16.15,3);
3. expected output : 1615
4. getting : 16149
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Input : 16.15
expected output : 1615
ACTUAL -
Output : 16149
REPRODUCIBILITY :
This bug can be reproduced occasionally.
---------- BEGIN SOURCE ----------
public class Temp {
public static void main(String arg[])
{
doubleToStringForMQ(16.15,3);
}
public static String doubleToStringForMQ(double p_val, int p_digits)
{
String str;
str = new Integer(new Double(p_val * java.lang.Math.pow(10, p_digits)).intValue()).toString();
System.out.println(str);
return str;
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
still working............
1.4.2_11, 1.5.0_06, 6.0_80
ADDITIONAL OS VERSION INFORMATION :
Windows 2000
Windows XP
Solaries
Linux
EXTRA RELEVANT SYSTEM CONFIGURATION :
JRE 1.2
under solaries jre platform in Websphere Application server 5.0
Windows 2000 workstation.
WAS 5.0/jdk 1.3 under Unix boxes.
A DESCRIPTION OF THE PROBLEM :
When I submit the values :
Input : 16.15,3
output: 16149
public static String doubleToStringForMQ(double p_val, int p_digits)
{
String str;
str = new Integer(new Double(p_val * java.lang.Math.pow(10, p_digits)).intValue()).toString();
System.out.println(str);
return str;
}
its happening for only this input, well atleast to my knowledge...
for instance if input : 16.13 o/p: 1613
if one calculates for input 16.15 o/p should be 1615 not 16149
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Call this method from any from any class:
public static String doubleToStringForMQ(double p_val, int p_digits)
{
String str;
str = new Integer(new Double(p_val * java.lang.Math.pow(10, p_digits)).intValue()).toString();
System.out.println(str);
return str;
}
2. call the above method with the following parameters:
doubleToStringForMQ(16.15,3);
3. expected output : 1615
4. getting : 16149
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Input : 16.15
expected output : 1615
ACTUAL -
Output : 16149
REPRODUCIBILITY :
This bug can be reproduced occasionally.
---------- BEGIN SOURCE ----------
public class Temp {
public static void main(String arg[])
{
doubleToStringForMQ(16.15,3);
}
public static String doubleToStringForMQ(double p_val, int p_digits)
{
String str;
str = new Integer(new Double(p_val * java.lang.Math.pow(10, p_digits)).intValue()).toString();
System.out.println(str);
return str;
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
still working............
- duplicates
-
JDK-4497156 double (primitive) arithmetic precision error
-
- Closed
-