[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [commit-cp] [bugs #9895] double to int conversion problem
From: |
Archie Cobbs |
Subject: |
Re: [commit-cp] [bugs #9895] double to int conversion problem |
Date: |
Thu, 5 Aug 2004 10:05:32 -0500 (CDT) |
David Gilbert wrote:
> public class DoubleToIntTest {
> public static void main(String args[]) {
> double v = Integer.MAX_VALUE + 100000.0;
> System.out.println((int) v);
> Double d = new Double(v);
> System.out.println(d.intValue());
> }
> }
>
> With Classpath (fairly recent CVS) running on JamVM 1.1.4 (on SuSE 9.1), I
> see the following output:
>
> -2147483648
> -2147483648
>
> Using Sun's JDK 1.4, the output is:
>
> 2147483647
> 2147483647
I think this is a VM bug rather than a Classpath bug (JC has the same
bug). It results from doing the jdouble -> jint conversion in C via
a `(jint)d' cast.
JC generates this code (edited)...
jdouble d2;
jint i1;
d2 = _JC_DCONST(0x41, 0xe0, 0x0, 0x30, 0xd3, 0xe0, 0x0, 0x0);
...
i1 = (jint)d2;
...
I'm still curious what the solution is though :-)
-Archie
__________________________________________________________________________
Archie Cobbs * CTO, Awarix * http://www.awarix.com