From mboxrd@z Thu Jan 1 00:00:00 1970 From: Joe Murray To: nobody@gcc.gnu.org Cc: gcc-prs@gcc.gnu.org Subject: RE: c/2582: implicit cast assignment from int to float problem with x86 Date: Mon, 23 Apr 2001 09:36:00 -0000 Message-id: <20010423163601.15246.qmail@sourceware.cygnus.com> X-SW-Source: 2001-04/msg00428.html List-Id: The following reply was made to PR c/2582; it has been noted by GNATS. From: Joe Murray To: "'gcc-gnats@gcc.gnu.org'" Cc: Subject: RE: c/2582: implicit cast assignment from int to float problem wi th x86 Date: Mon, 23 Apr 2001 12:42:43 -0400 All, Intel has provided the following explanation. Is there a flag in GCC that may do something similar? Is there a mechanism that supports forcing a register assignment when an exectuable is run? Intel response: Hi Joseph, Here's what we've found. When running C language on Intel processors, the most popular compilers including Microsoft* Visual C++, Borland C, Turbo C and GNU would encounter rounding errors when doing floating point calculations. The floating point unit located within the processor has 4 rounding modes (round to nearest, round down, round up and truncate) and 3 precision modes (24-bit, 53-bit and 64-bit). The default mode for Intel processors is round to nearest. Unfortunately, the rounding mode would get changed to truncate, resulting in a round-off error. The easiest solution would be to add a few lines of inline assembly that would change the round mode to round to nearest. short example; //Loads the FPU Control register to X. _asm { fstsw ax mov x,ax } //Perform a bitwise OR to change rounding mode (bit 10-11) to "To nearest (00). //48D=0000001100000000B //For more information on the FPU control reference refer to the Software Developer's Manual x=x|48; //Takes X back to the FPU Control Register _asm { fldcw x; } Randy S. Intel(R) Technical Support Engineer *Other names and brands may be claimed as the property of others. -----Original Message----- From: gcc-gnats@gcc.gnu.org [ mailto:gcc-gnats@gcc.gnu.org ] Sent: Wednesday, April 18, 2001 5:36 PM To: jmurray@dsrnet.com Subject: Re: c/2582: implicit cast assignment from int to float problem with x86 Thank you very much for your problem report. It has the internal identification `c/2582'. The individual assigned to look at your report is: unassigned. >Category: c >Responsible: unassigned >Synopsis: implicit cast assignment from int to float problem with x86 >Arrival-Date: Wed Apr 18 14:36:01 PDT 2001