[kaffe] Simple program shows strange results
Ito Kazumitsu
ito.kazumitsu@hitachi-cable.co.jp
Wed Mar 5 16:32:01 2003
In message "Re: [kaffe] Simple program shows strange results"
on 03/03/05, Ito Kazumitsu <kaz@maczuka.gcd.org> writes:
> I have made a simpler test program:
This strange problem occurs with float and double, but not
with int or byte.
$ cat Test.java.m4
public class Test {
public static void main(String[] args) {
T x = C1;
if (x < C2) {
System.err.println("x<C2: " + x);
x = C2;
}
System.err.println(x);
}
}
$ echo 'define(T,float)define(C1,10f)define(C2,7f)dnl'| m4 - Test.java.m4 > Test.java; javac Test.java; java Test
4.7761093E-34
$ echo 'define(T,double)define(C1,10d)define(C2,7d)dnl'| m4 - Test.java.m4 > Test.java; javac Test.java; java Test
1.4534249933639232E-269
$ echo 'define(T,int)define(C1,10)define(C2,7)dnl'| m4 - Test.java.m4 > Test.java; javac Test.java; java Test
10
$ echo 'define(T,byte)define(C1,10)define(C2,7)dnl'| m4 - Test.java.m4 > Test.java; javac Test.java; java Test
10
$ echo 'define(T,long)define(C1,10)define(C2,7)dnl'| m4 - Test.java.m4 > Test.java; javac Test.java; java Test
10
$