Details
-
Bug
-
Status: Open
-
Major
-
Resolution: Unresolved
-
3.8.1
-
None
-
None
Description
The following code demonstrates the issue:
System.out.println(NumberUtils.createNumber("1.1").getClass().getName());
System.out.println(NumberUtils.createNumber("1.001").getClass().getName());
System.out.println(NumberUtils.createNumber("1.00001").getClass().getName());
System.out.println(NumberUtils.createNumber("1.0000001").getClass().getName());
System.out.println(NumberUtils.createNumber("1.000000001").getClass().getName());
System.out.println(NumberUtils.createNumber("1.00000000001").getClass().getName());
System.out.println(NumberUtils.createNumber("1.0000000000001").getClass().getName());
System.out.println(NumberUtils.createNumber("1.000000000000001").getClass().getName());
System.out.println(NumberUtils.createNumber("1.00000000000000001").getClass().getName());
System.out.println(NumberUtils.createNumber("1.0000000000000000001").getClass().getName());
System.out.println(NumberUtils.createNumber("1.000000000000000000001").getClass().getName());
System.out.println(NumberUtils.createNumber("1.00000000000000000000001").getClass().getName());
will print:
java.lang.Float
java.lang.Float
java.lang.Float
java.lang.Float
java.lang.Double
java.lang.Double
java.lang.Double
java.lang.Double
java.lang.Float
java.lang.Float
java.lang.Float
java.lang.Float
It seems the problem is towards the bottom of the createNumber method that compares the float to double string representation:
f.toString().equals(d.toString())
For the misbehaving tests, the string "1.0".equals("1.0")