Mail Archives: djgpp-workers/2003/08/11/19:42:54
--part1_1dc.f218ef8.2c698135_boundary
Content-Type: text/plain; charset="US-ASCII"
Content-Transfer-Encoding: 7bit
Yet another anomaly? How can rounding mode change integral output?
#include <stdio.h>
#include <float.h>
int
main(void)
{
long double Demo = (unsigned long long)(-1);
long double DemoM1 = Demo - 1.0L;
printf("Begin with Rounding Mode at Startup\n");
printf("Demo = %.3Lf\n", Demo);
printf("Demo - 1 = %.3Lf\n", DemoM1);
_control87(RC_UP, RC_UP);
printf("New Rounding Mode is RC_UP = %.4x\n", RC_UP);
printf("Demo = %.3Lf\n", Demo);
printf("Demo - 1 = %.3Lf\n", DemoM1);
exit(0);
}
Begin with Rounding Mode at Startup
Demo = 18446744073709551615.000
Demo - 1 = 18446744073709551613.000
New Rounding Mode is RC_UP = 0800
Demo = 18446744073709551616.000
Demo - 1 = 18446744073709551615.000
--part1_1dc.f218ef8.2c698135_boundary
Content-Type: text/html; charset="US-ASCII"
Content-Transfer-Encoding: quoted-printable
<HTML><FONT FACE=3Darial,helvetica><FONT SIZE=3D3 FAMILY=3D"SERIF" FACE=3D"=
Georgia" LANG=3D"0">Yet another anomaly? How can rounding mode change=20=
integral output?<BR>
<BR>
#include <stdio.h><BR>
#include <float.h><BR>
int<BR>
main(void)<BR>
{<BR>
long double Demo =3D (unsigned long long)(-1)=
;<BR>
long double DemoM1 =3D Demo - 1.0L;<BR>
<BR>
printf("Begin with Rounding Mode at Startup\n");<BR>
printf("Demo =3D %.3Lf\n", Demo);=
<BR>
printf("Demo - 1 =3D %.3Lf\n", DemoM1);<BR>
<BR>
_control87(RC_UP, RC_UP);<BR>
<BR>
printf("New Rounding Mode is RC_UP =3D %.4x\n", RC_UP);<B=
R>
printf("Demo =3D %.3Lf\n", Demo);=
<BR>
printf("Demo - 1 =3D %.3Lf\n", DemoM1);<BR>
exit(0);<BR>
}<BR>
Begin with Rounding Mode at Startup<BR>
Demo =3D 18446744073709551615.000<BR>
Demo - 1 =3D 18446744073709551613.000<BR>
<BR>
New Rounding Mode is RC_UP =3D 0800<BR>
Demo =3D 18446744073709551616.000<BR>
Demo - 1 =3D 18446744073709551615.000<BR>
</FONT></HTML>
--part1_1dc.f218ef8.2c698135_boundary--
- Raw text -