GCC Bugzilla – Bug 12059
jcf-dump does not display float constants to fixed precission
Last modified: 2005-09-30 13:31:46 UTC
There seems to be precision errors in the display of Float constants by jcf-dump
blanche ~/tmp/bug cat Float.java [01:09 26/08/03]
public static void main(String args)
double d = 1.1;
blanche ~/tmp/bug javac Float.java [01:09 26/08/03]
blanche ~/tmp/bug java Float [01:10 26/08/03]
The problem is when disassembling the class file. javap does it correctly:
blanche ~/tmp/bug javap -c Float [01:10 26/08/03]
Compiled from Float.java
Method void main(java.lang.String)
0 ldc2_w #2 <Double 1.1>
jcf-dump writes instead:
blanche ~/tmp/bug jcf-dump-3.3 -c Float.class [01:10 26/08/03]
Method name:"main" public static Signature: 13=(java.lang.String)void
Attribute "Code", length:44, max_stack:3, max_locals:3, code_length:12
0: ldc2_w #2=<Double 1.1000000000000000888>
Not a bug as 1.1 cannot be be repesentive exactly in a floating point number (jcf-dump is just
writting more precision out any way so it should not matter).
I'm not certain this is not a bug.
Ideally jcf-dump would follow java rules for printing
these constants, though that might be hard to achieve.
It was unthoughtful for me not to set severity to "enhancement" and priority to
1. Indeed, this is not a bug. I understand that 1.1000000000000000888 is the
same double as 1.1. However, I think it is much nicer to see the later than the
former (formally, nicer actually means shorter). The difference in decimal
representation lead me on a wrong track, when debuging a compiler. So it does
make a difference.
javap and dis both use the expected representation.
So I hope you won't mind that I reopen the report, now with low severity and
P3 is the lowest, not P1.