This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug target/12129] New: Unexpected loss of floating point precision in assignment


PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12129

           Summary: Unexpected loss of floating point precision in
                    assignment
           Product: gcc
           Version: 3.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: target
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: preciseflight at yahoo dot com dot au
                CC: gcc-bugs at gcc dot gnu dot org

#include <stdio.h>

#define OP(x) ((x) * .29425635593220338949)

int main (void) {
        double a = 5671.92506245995003720887;
        double b = OP (a);

        printf ("%d %d\n", (int) OP (a), (int) b);

        return 0;
}

On an i386 (gcc 2.95.4, 3.3), the output is:
1668 1669

Clearly, looking at the code, these 2 numbers should be equal!

However, on a sparc (gcc 2.95.3), the output is correct:
1669 1669


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]