public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: where to discuss problems with IEEE 754 standard on x86 architecture?
@ 2007-05-22 20:41 Nick Maclaren
  2007-05-23  7:44 ` Petr Savicky
  0 siblings, 1 reply; 10+ messages in thread
From: Nick Maclaren @ 2007-05-22 20:41 UTC (permalink / raw)
  To: gcc-help, Petr Savicky

I was being stupid.  Sorry.  My reply was correct but unhelpful.

You were using -mfpmath=387 (possible as the default), and that uses
Intel native arithmetic, which is NOT standard IEEE 754 double, but
an extended format.

If you use -mfpmath=sse, you will get what you expect.


Regards,
Nick Maclaren,
University of Cambridge Computing Service,
New Museums Site, Pembroke Street, Cambridge CB2 3QH, England.
Email:  nmm1@cam.ac.uk
Tel.:  +44 1223 334761    Fax:  +44 1223 334679

^ permalink raw reply	[flat|nested] 10+ messages in thread
* Re: where to discuss problems with IEEE 754 standard on x86 architecture?
@ 2007-05-22 20:25 Nick Maclaren
  0 siblings, 0 replies; 10+ messages in thread
From: Nick Maclaren @ 2007-05-22 20:25 UTC (permalink / raw)
  To: gcc-help

Petr Savicky <savicky@cs.cas.cz> wrote:
>
> Can anybody help me to find the right place to discuss the problems
> related to IEEE 754 standard for floating point numbers on x86 (IA-32)?

Well, I could, but they wouldn't be terribly pleased.  Your error is
to assume that IEEE 754 applies to composite operations, whereas it
actually applies to each basic one in turn.  To see what is going on,
you should print out the balues in binary, octal or hexadecimal, for
each sub-operation.

As far as I can see, gcc is doing nothing wrong.


Regards,
Nick Maclaren,
University of Cambridge Computing Service,
New Museums Site, Pembroke Street, Cambridge CB2 3QH, England.
Email:  nmm1@cam.ac.uk
Tel.:  +44 1223 334761    Fax:  +44 1223 334679

^ permalink raw reply	[flat|nested] 10+ messages in thread
* where to discuss problems with IEEE 754 standard on x86 architecture?
@ 2007-05-22 20:05 Petr Savicky
  2007-05-22 20:06 ` John (Eljay) Love-Jensen
  2007-05-23 12:54 ` Andrew Haley
  0 siblings, 2 replies; 10+ messages in thread
From: Petr Savicky @ 2007-05-22 20:05 UTC (permalink / raw)
  To: gcc-help

Can anybody help me to find the right place to discuss the problems
related to IEEE 754 standard for floating point numbers on x86 (IA-32)?

The following code
  #include <stdio.h>
  
  int main(int argc, char *argv[]) {
      double x,y,z,m=1.0;
      for (int i=0; i<52; i++) { m *= 2.0; }
  
      x = 1.5 - 1.0/4096.0 - 1.0/m;
      y = 1.5 - 1.0/4096.0;
  
      z = 1.0 + 1.0/m*x;
      printf("%f\n",m*(z-1.0));
  
      z = 1.0 + 1.0/m*y;
      printf("%f\n",m*(z-1.0));
  }
produces output
  1.000000
  2.000000
on x86 (IA-32) processor. In my opinion, this implies that IA-32 processor
does not follow IEEE 754 exactly, since the closest representable
value to both 1.0 + 1.0/m*x and 1.0 + 1.0/m*y is z = 1.0 + 1.0/m
and not z = 1.0 + 2.0/m, which is obtained in the second case.

Am I right? If yes, I think that the problem is known. Are there web
pages or other resources on this problem?

Thank you very much for any information.

All the best, Petr.

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2007-05-23 16:04 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-05-22 20:41 where to discuss problems with IEEE 754 standard on x86 architecture? Nick Maclaren
2007-05-23  7:44 ` Petr Savicky
2007-05-23  8:17   ` Nick Maclaren
2007-05-23  8:46   ` Brian Dessent
2007-05-23 13:30   ` Tim Prince
2007-05-23 17:23     ` Petr Savicky
  -- strict thread matches above, loose matches on Subject: below --
2007-05-22 20:25 Nick Maclaren
2007-05-22 20:05 Petr Savicky
2007-05-22 20:06 ` John (Eljay) Love-Jensen
2007-05-23 12:54 ` Andrew Haley

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).