Different results of java and C verion of same program ?

David Balažic david.balazic@hermes.si
Fri Mar 3 11:32:00 GMT 2006


Hi!

I use gcc 3.3.5 (debian 3.1).
*
I have written a program in jav*a and compiled it with gcj.
Then I ported it to C and compiled with gcc.

They give different results !

What the program does :
 - load point 4D coordinates from a an ASCII file
(format is one point per line, like :
0.146584576854345 0.234453109584343 0.544867765645423
the values are mostly between 0 and 1 , about 15 decimals)
 - convert values to double
 - compute distance between points
 - sort distances and print it out (sorted)

The java version gives slightly different output than C.
Also if I modify the C version to use "long double" type
instead of "double" I get again different results (this time more
similar to the C result).

Can this be some compiler error ?
Computing accuracy related ?

Regards,
David



More information about the Java mailing list