public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: _FP_SETCW()
@ 2001-05-08 12:08 tprinceusa
  0 siblings, 0 replies; 2+ messages in thread
From: tprinceusa @ 2001-05-08 12:08 UTC (permalink / raw)
  To: Philippe Després; +Cc: gcc

Philippe =?iso-8859-1?Q?Despr=E9s?= <p0663835@magellan.umontreal.ca> wrote:
> Hello,

anyone know how to set the control word from fpu_control.h to obtain a
floating point behavior like the one on Windows (VC++), i.e. that for a
double, 

double x=cos(0.2); 

printf("%20.20f",x); on windows gives
 x=0.98006657784124163000 (zeros after the 17th digit)

on linux, those zeros are filled with something else and my results
depends on this...

Actually, I use 

fpu_control_t fp_ctrl;
fp_ctrl=(_FPU_DEFAULT & ~ _FPU_EXTENDED)|_FPU_DOUBLE;
_FPU_SETCW(fp_ctrl);

before calculation.
Thanks
Philippe

You are mixing enough issues together that it is difficult to tell what you want.  Yes, you can set the ia32 processor to 53-bit rounding mode, as VC++ does without giving you an option.  Whether the way you mention is the right one for your linux installation depends on which library you have.  Unless you use long double formats in your conversion, and leave the cpu in long double rounding mode, digits after the 17th are meaningless.  The IEEE 754 standard specifically required 17 significant digits when in 53-bit rounding mode, and specifically allows the remainder to be set zero or implementation dependent.  If your program requires 53-bit rounding mode and depends on the digits beyond the 17th, it could be considered erroneous.

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

* _FP_SETCW()
@ 2001-05-08 10:33 Philippe Després
  0 siblings, 0 replies; 2+ messages in thread
From: Philippe Després @ 2001-05-08 10:33 UTC (permalink / raw)
  To: gcc

Hello,

anyone know how to set the control word from fpu_control.h to obtain a
floating point behavior like the one on Windows (VC++), i.e. that for a
double, 

double x=cos(0.2); 

printf("%20.20f",x); on windows gives
 x=0.98006657784124163000 (zeros after the 17th digit)

on linux, those zeros are filled with something else and my results
depends on this...

Actually, I use 

fpu_control_t fp_ctrl;
fp_ctrl=(_FPU_DEFAULT & ~ _FPU_EXTENDED)|_FPU_DOUBLE;
_FPU_SETCW(fp_ctrl);

before calculation.
Thanks
Philippe

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

end of thread, other threads:[~2001-05-08 12:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-05-08 12:08 _FP_SETCW() tprinceusa
  -- strict thread matches above, loose matches on Subject: below --
2001-05-08 10:33 _FP_SETCW() Philippe Després

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