You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by "Mikhail Fursov (JIRA)" <ji...@apache.org> on 2007/04/15 16:01:15 UTC

[jira] Created: (HARMONY-3655) [drlvm]All JITs and interpreter perform incorrect floating point division when dividend is -0.0

[drlvm]All JITs and interpreter perform incorrect floating point division when dividend is -0.0
-----------------------------------------------------------------------------------------------

                 Key: HARMONY-3655
                 URL: https://issues.apache.org/jira/browse/HARMONY-3655
             Project: Harmony
          Issue Type: Bug
          Components: DRLVM
            Reporter: Mikhail Fursov


For the test below:
public class Hello {
    static float a=0f, b=-1f, c=1f, d=-0f;
    public static void main(String[] args) {
        float res;

        res = ((a * b) % c);     
        System.out.println("res="+res);   
        
        res = d % c;
        System.out.println("res="+res);
    }
}


The same problem we have for 'double' type

RI output is:
res=-0.0
res=-0.0

When JET/OPT/Interpreter print:
res=0.0
res=0.0

I think that the problem is with VM helper.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (HARMONY-3655) [drlvm][helpers] All JITs and interpreter perform incorrect floating point division when dividend is -0.0

Posted by "Alexey Varlamov (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HARMONY-3655?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12530422 ] 

Alexey Varlamov commented on HARMONY-3655:
------------------------------------------

Yes, we better provide math support in portlib.

> [drlvm][helpers] All JITs and interpreter perform incorrect floating point division when dividend is -0.0
> ---------------------------------------------------------------------------------------------------------
>
>                 Key: HARMONY-3655
>                 URL: https://issues.apache.org/jira/browse/HARMONY-3655
>             Project: Harmony
>          Issue Type: Bug
>          Components: DRLVM
>         Environment: win32
>            Reporter: Mikhail Fursov
>
> For the test below:
> public class Hello {
>     static float a=0f, b=-1f, c=1f, d=-0f;
>     public static void main(String[] args) {
>         float res;
>         res = ((a * b) % c);     
>         System.out.println("res="+res);   
>         
>         res = d % c;
>         System.out.println("res="+res);
>     }
> }
> The same problem we have for 'double' type
> RI output is:
> res=-0.0
> res=-0.0
> When JET/OPT/Interpreter print:
> res=0.0
> res=0.0
> I think that the problem is with VM helper.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (HARMONY-3655) [drlvm][helpers] All JITs and interpreter perform incorrect floating point division when dividend is -0.0

Posted by "Gregory Shimansky (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HARMONY-3655?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Gregory Shimansky updated HARMONY-3655:
---------------------------------------

    Summary: [drlvm][helpers] All JITs and interpreter perform incorrect floating point division when dividend is -0.0  (was: [drlvm]All JITs and interpreter perform incorrect floating point division when dividend is -0.0)

> [drlvm][helpers] All JITs and interpreter perform incorrect floating point division when dividend is -0.0
> ---------------------------------------------------------------------------------------------------------
>
>                 Key: HARMONY-3655
>                 URL: https://issues.apache.org/jira/browse/HARMONY-3655
>             Project: Harmony
>          Issue Type: Bug
>          Components: DRLVM
>            Reporter: Mikhail Fursov
>
> For the test below:
> public class Hello {
>     static float a=0f, b=-1f, c=1f, d=-0f;
>     public static void main(String[] args) {
>         float res;
>         res = ((a * b) % c);     
>         System.out.println("res="+res);   
>         
>         res = d % c;
>         System.out.println("res="+res);
>     }
> }
> The same problem we have for 'double' type
> RI output is:
> res=-0.0
> res=-0.0
> When JET/OPT/Interpreter print:
> res=0.0
> res=0.0
> I think that the problem is with VM helper.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (HARMONY-3655) [drlvm][helpers] All JITs and interpreter perform incorrect floating point division when dividend is -0.0

Posted by "Gregory Shimansky (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HARMONY-3655?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12530138 ] 

Gregory Shimansky commented on HARMONY-3655:
--------------------------------------------

I wrote a small program that does the same as your test, and when I run this program compiled with MSVC, it produces an incorrect output (same goes for double):

#include <math.h>

#include <stdio.h>



int main(void)

{

    static float a=0.0f, b=-1.0f, c=1.0f, d=-0.0f;

    static float res;

    static unsigned aaa = 0x80000000;



    res = fmodf(a * b, c);

    printf("%f\n", res);



    res = fmodf(d, c);

    printf("%f\n", res);



    *((unsigned*)(&d)) = aaa;



    res = fmodf(d, c);

    printf("%f\n", res);

}

I think the problem is with MSVC (both 2003 and 2005) runtime implementation of fmod. It just doesn't care about the sign on 0.0 value and assumes it is zero. On Linux this test works correctly.

In interpreter and runtime helper VM uses fmod runtime function, that's the cause of the problem. Is it possible to use jitrino_ieee754_fmod_double from JIT code instead?

> [drlvm][helpers] All JITs and interpreter perform incorrect floating point division when dividend is -0.0
> ---------------------------------------------------------------------------------------------------------
>
>                 Key: HARMONY-3655
>                 URL: https://issues.apache.org/jira/browse/HARMONY-3655
>             Project: Harmony
>          Issue Type: Bug
>          Components: DRLVM
>         Environment: win32
>            Reporter: Mikhail Fursov
>
> For the test below:
> public class Hello {
>     static float a=0f, b=-1f, c=1f, d=-0f;
>     public static void main(String[] args) {
>         float res;
>         res = ((a * b) % c);     
>         System.out.println("res="+res);   
>         
>         res = d % c;
>         System.out.println("res="+res);
>     }
> }
> The same problem we have for 'double' type
> RI output is:
> res=-0.0
> res=-0.0
> When JET/OPT/Interpreter print:
> res=0.0
> res=0.0
> I think that the problem is with VM helper.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (HARMONY-3655) [drlvm][helpers] All JITs and interpreter perform incorrect floating point division when dividend is -0.0

Posted by "Gregory Shimansky (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HARMONY-3655?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Gregory Shimansky updated HARMONY-3655:
---------------------------------------

    Environment: win32

I checked this bug on 4 platforms and found out that it happens only on win32. On Linuxes and win64 all results are correct. So I changed the environment for it.

> [drlvm][helpers] All JITs and interpreter perform incorrect floating point division when dividend is -0.0
> ---------------------------------------------------------------------------------------------------------
>
>                 Key: HARMONY-3655
>                 URL: https://issues.apache.org/jira/browse/HARMONY-3655
>             Project: Harmony
>          Issue Type: Bug
>          Components: DRLVM
>         Environment: win32
>            Reporter: Mikhail Fursov
>
> For the test below:
> public class Hello {
>     static float a=0f, b=-1f, c=1f, d=-0f;
>     public static void main(String[] args) {
>         float res;
>         res = ((a * b) % c);     
>         System.out.println("res="+res);   
>         
>         res = d % c;
>         System.out.println("res="+res);
>     }
> }
> The same problem we have for 'double' type
> RI output is:
> res=-0.0
> res=-0.0
> When JET/OPT/Interpreter print:
> res=0.0
> res=0.0
> I think that the problem is with VM helper.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.