harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Gregory Shimansky (JIRA)" <j...@apache.org>
Subject [jira] Commented: (HARMONY-3655) [drlvm][helpers] All JITs and interpreter perform incorrect floating point division when dividend is -0.0
Date Tue, 25 Sep 2007 15:47:50 GMT

    [ 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.


Mime
View raw message