Bug List: (This bug is not in your last search results)   Show last search results      Search page      Enter new bug
Bug#: 12129
Product:  
Component:  
Status: RESOLVED
Resolution: DUPLICATE of bug 323
Assigned To: Not yet assigned to anyone <unassigned@gcc.gnu.org>
Host:
Reported against  
Priority:  
Severity:  
Target Milestone:  
 
 
Target:
Reporter: preciseflight@yahoo.com.au
Add CC:
CC:
Remove selected CCs
Build:
URL:
Summary:
Keywords:
Known to work:
Known to fail:

Attachment Description Type Created Size Actions
Create a New Attachment (proposed patch, testcase, etc.) View All

Bug 12129 depends on: Show dependency tree
Show dependency graph
Bug 12129 blocks:

Additional Comments:






View Bug Activity   |   Format For Printing   |   Clone This Bug


Description:   Last confirmed: Opened: 2003-09-02 05:04
#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

------- Comment #1 From Andrew Pinski 2003-09-02 13:34 -------
This is a non bug, read <http://gcc.gnu.org/bugs.html#nonbugs_general>
Also read bug 323 which is a dup of.

*** This bug has been marked as a duplicate of 323 ***

------- Comment #2 From preciseflight@yahoo.com.au 2003-09-03 05:30 -------
Subject: Re:  Unexpected loss of floating point precision in assignment


Hello,

I'm confused:

> ------- Additional Comments From
pinskia@gcc.gnu.org:
> This is a non bug, read
> <http://gcc.gnu.org/bugs.html#nonbugs_general>
> 
I understand that floating point arithmetic is
inaccurate but I don't understand how _assigning_ a
floating point value to a variable before use could
be any different from the implicit assignment of the
value to a temporary variable (done by the compiler).

> *** This bug has been marked as a duplicate of 323
But this has nothing to do with optimization levels.
I'm compiling with optimization off.


http://search.yahoo.com.au - Yahoo! Search
- Looking for more? Try the new Yahoo! Search

------- Comment #3 From Andrew Pinski 2003-09-03 05:37 -------
assigning it to a temporary variable forces (by placing in memory by having no
optimizations) a 
change in floating point precision and causes rounding to take place which
causes more havoc 
than you think so this is still a dup of bug 323.

Bug List: (This bug is not in your last search results)   Show last search results      Search page      Enter new bug