• Bug#266224: sablevm: error with floating point numbers

    From Grzegorz B. Prokopski@1:229/2 to All on Fri Aug 20 03:20:07 2004
    From: [email protected]

    reopen 266224
    thanks

    Hi Rogerio,

    I was definitely too fast to close this bugreport. We have similar (in apperance) bug filled upstream and I believed this problem will go away
    once we switch from 80-bit floats to 64 bit floats on Intel. I was
    wrong, as the problem you've pointed out shows just as well on sparc.

    It needs further investigation, so I leave it open.

    Thank you for reporting the problem,

    Grzegorz B. Prokopski

    PS: Intrestingly, this C program shows similar behaviour:

    int main(void) {

    long long l = 0x7fffffffffffffff;
    double d = l;
    long long l2 = d;


    printf("l : %lli\n", l);
    printf("d : %d\n", d);
    printf("l2: %lli\n", l2);
    }

    As SableVM is written in pure C, understanding the effect we get in
    C program should allow us to fix the problem in SableVM.

    W li�cie z pon, 16-08-2004, godz. 23:38, Rog�rio Brito pisze:
    Package: sablevm
    Version: 1.1.6-2
    Severity: important

    Since some free Java virtual machines started to appear in testing, I began to learn Java. Unfortunately, when I try to compile a small program given
    in my textbook, I got a strange result when using sablevm. Here is what I get:

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Script started on Tue Aug 17 00:28:24 2004
    rbrito@chagas:~/src$ sablevm --no-copyright Precision
    l = 9223372036854775807
    d = 9.223372036854776E18
    l2 = -9223372036854775808
    rbrito@chagas:~/src$ kaffe Precision
    l = 9223372036854775807
    d = 9.223372036854776E18
    l2 = 9223372036854775807
    rbrito@chagas:~/src$
    Script done on Tue Aug 17 00:28:45 2004

    --
    Grzegorz B. Prokopski <[email protected]>
    Debian GNU/Linux http://www.debian.org
    SableVM - LGPL'ed Java VM http://www.sablevm.org
    Why SableVM ?!? http://devel.sablevm.org/wiki/Features

    --- SoupGate-Win32 v1.05
    * Origin: you cannot sedate... all the things you hate (1:229/2)
  • From Grzegorz B. Prokopski@1:229/2 to All on Fri Aug 20 04:40:09 2004
    From: [email protected]

    severity 266224 normal
    tags 266224 upstream
    thanks

    Hi again,

    The problem has been forwarded upstream, see http://sablevm.org/bugs/54
    for further details.

    In short, a check for overflow during conversion from float/double to long/integer types is missing, and if the value can not be held in
    the long/integer type - an overflow happens and the result is wrong.

    This definitely is a bug, but it happens only if you use really big
    values and happen to convert them from floats/doubles to long/integers.
    There are no JVM crashes or other terribly bad effects. Therefore
    I change the severity of this bug to normal.

    Thank you very much for reporting this problem.

    Please let us know if you find any other problems while using SableVM
    to learn Java.

    Good luck!

    Grzegorz B. Prokopski

    --
    Grzegorz B. Prokopski <[email protected]>
    Debian GNU/Linux http://www.debian.org
    SableVM - LGPL'ed Java VM http://www.sablevm.org
    Why SableVM ?!? http://devel.sablevm.org/wiki/Features



    --
    To UNSUBSCRIBE, email to [email protected]
    with a subject of "unsubscribe". Trouble? Contact [email protected]

    --- SoupGate-Win32 v1.05
    * Origin: you cannot sedate... all the things you hate (1:229/2)
  • From =?iso-8859-1?Q?Rog=E9rio?= Brito@1:229/2 to Grzegorz B. Prokopski on Fri Aug 20 05:30:08 2004
    From: [email protected]

    On Aug 19 2004, Grzegorz B. Prokopski wrote:
    The problem has been forwarded upstream, see http://sablevm.org/bugs/54
    for further details.

    Thank you very much for your feedback, Grzegorz.

    This definitely is a bug, but it happens only if you use really big
    values and happen to convert them from floats/doubles to long/integers.
    There are no JVM crashes or other terribly bad effects. Therefore
    I change the severity of this bug to normal.

    No problems. I think that I reported it with wrong severity. You are
    right. The bug only occurs too rarely.

    Please let us know if you find any other problems while using SableVM to learn Java.

    Heh, I will try to come up with pathological examples while trying to
    learn Java.


    Thanks for your nice feedback, Rog�rio.

    P.S.: I wish other developers were so kind and prompt as you.
    --
    =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    Rog�rio Brito - [email protected] - http://www.ime.usp.br/~rbrito =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

    --- SoupGate-Win32 v1.05
    * Origin: you cannot sedate... all the things you hate (1:229/2)
  • From =?iso-8859-1?Q?Rog=E9rio?= Brito@1:229/2 to All on Tue Aug 17 06:00:09 2004
    From: [email protected]

    Package: sablevm
    Version: 1.1.6-2
    Severity: important

    Since some free Java virtual machines started to appear in testing, I began
    to learn Java. Unfortunately, when I try to compile a small program given
    in my textbook, I got a strange result when using sablevm. Here is what I
    get:

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Script started on Tue Aug 17 00:28:24 2004
    rbrito@chagas:~/src$ sablevm --no-copyright Precision
    l = 9223372036854775807
    d = 9.223372036854776E18
    l2 = -9223372036854775808
    rbrito@chagas:~/src$ kaffe Precision
    l = 9223372036854775807
    d = 9.223372036854776E18
    l2 = 9223372036854775807
    rbrito@chagas:~/src$
    Script done on Tue Aug 17 00:28:45 2004
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    I compiled the code with jikes-sablevm. I think that the result that kaffe gives is the correct one.

    I'm attaching the source file of Precision.java with this mail.

    -- System Information:
    Debian Release: 3.1
    APT prefers testing
    APT policy: (500, 'testing')
    Architecture: i386 (i686)
    Kernel: Linux 2.6.7-6
    Locale: LANG=C, LC_CTYPE=C

    Versions of packages sablevm depends on:
    ii java-common 0.22 Base of all Java packages
    ii libc6 2.3.2.ds1-13 GNU C Library: Shared libraries an ii libpopt0 1.7-4 lib for parsing cmdline parameters ii libsablevm1 1.1.6-2 Free implementation of JVM second ii unzip 5.51-2 De-archiver for .zip files

    -- no debconf information

    class Precision {
    public static void main(String[] args) {
    long l=0x7fffffffffffffffL;
    double d=l;
    long l2=(long)d;

    System.out.println("l = " + l);
    System.out.println("d = " + d);
    System.out.println("l2 = " + l2);
    }
    }



    --- SoupGate-Win32 v1.05
    * Origin: you cannot sedate... all the things you hate (1:229/2)