delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2003/10/14/13:25:45

X-Authentication-Warning: delorie.com: mail set sender to djgpp-workers-bounces using -f
From: Kbwms AT aol DOT com
Message-ID: <27.4950dd26.2cbd8b44@aol.com>
Date: Tue, 14 Oct 2003 13:24:20 EDT
Subject: Re: Work on C99 Math Functions
To: djgpp-workers AT delorie DOT com
MIME-Version: 1.0
X-Mailer: 8.0 for Windows sub 6015
Reply-To: djgpp-workers AT delorie DOT com

--part1_27.4950dd26.2cbd8b44_boundary
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: quoted-printable


My work on the C99 math library continues. =A0 One of the problems that aris=
es=20
is what to do in when an error is detected in a math function. =A0 For examp=
le,=20
the following is quoted from the specs for remainder functions:

RETURN VALUE

> These functions shall return x REM y.


Optionally:

>=20
> If x or y is NaN, a NaN shall be returned.
>=20
> If x is =B1Inf or y is zero and the other argument is non-NaN, a domain er=
ror=20
> shall occur, and either a NaN (if supported), or an implementation-defined=
=20
> value shall be returned.=20
>=20


ERRORS (optional)

> These functions shall fail if:
>=20
> Domain=A0Error:


> The x argument is =B1Inf, or the y argument is =B10 and the other argument=
 is=20
> non-NaN. If the integer expression (math_errhandling & MATH_ERRNO) is=20
> non-zero, then errno shall be set to [EDOM]. If the integer expression=20
> (math_errhandling & MATH_ERREXCEPT) is non-zero, then the invalid floating=
-point exception=20
> shall be raised.

MATH_ERRNO, MATH_ERREXCEPT & math_errhandling are described in=20

<A HREF=3D"http://www.opengroup.org/onlinepubs/007904975/basedefs/math.h.htm=
l">http://www.opengroup.org/onlinepubs/007904975/basedefs/math.h.html</A>

No official decision has been made on how errors are to be handled, to the=20
best of my knowledge.

My approach is, "more is better."=A0 So, all of the above went into the new=20
remainder functions except for testing (math_errhandling & MATH_ERRNO) or=20
(math_errhandling & MATH_ERREXCEPT).=A0 That is, when a domain error occurs,=
 errno is=20
always set to EDOM and the invalid floating-point exception is always raised=
. =20
Requirements for other functions vary.

Is this the preferred approach? =A0 If it isn't, what is?



KB Williams

--part1_27.4950dd26.2cbd8b44_boundary
Content-Type: text/html; charset="ISO-8859-1"
Content-Transfer-Encoding: quoted-printable

<HTML><FONT FACE=3Darial,helvetica><FONT  SIZE=3D3 FAMILY=3D"SERIF" FACE=3D"=
Georgia" LANG=3D"0"><BR>
My work on the C99 math library continues. =A0 One of the problems that aris=
es is what to do in when an error is detected in a math function. =A0 For ex=
ample, the following is quoted from the specs for remainder functions:<BR>
<BR>
</FONT><FONT  COLOR=3D"#000000" style=3D"BACKGROUND-COLOR: #ffffff" SIZE=3D2=
 FAMILY=3D"SANSSERIF" FACE=3D"Arial" LANG=3D"0">RETURN VALUE<BR>
<BR>
<BLOCKQUOTE TYPE=3DCITE style=3D"BORDER-LEFT: #0000ff 2px solid; MARGIN-LEFT=
: 5px; MARGIN-RIGHT: 0px; PADDING-LEFT: 5px">These functions shall return <I=
>x</I> REM <I>y</I>.</BLOCKQUOTE><BR>
<BR>
<BR>
Optionally:<BR>
<BR>
<BLOCKQUOTE TYPE=3DCITE style=3D"BORDER-LEFT: #0000ff 2px solid; MARGIN-LEFT=
: 5px; MARGIN-RIGHT: 0px; PADDING-LEFT: 5px"><BR>
If <I>x</I> or <I>y</I> is NaN, a NaN shall be returned.<BR>
<BR>
If <I>x</I> is =B1Inf or <I>y</I> is zero and the other argument is non-NaN,=
 a domain error shall occur, and either a NaN (if supported), or an implemen=
tation-defined value shall be returned. <IMG  SRC=3D"http://www.opengroup.or=
g/onlinepubs/007904975/images/opt-end.gif" WIDTH=3D"14" HEIGHT=3D"9" BORDER=
=3D"0"><BR>
</BLOCKQUOTE><BR>
</FONT><FONT  COLOR=3D"#000000" style=3D"BACKGROUND-COLOR: #ffffff" SIZE=3D3=
 FAMILY=3D"SERIF" FACE=3D"Georgia" LANG=3D"0"><BR>
<BR>
ERRORS (optional)<BR>
</FONT><FONT  COLOR=3D"#000000" style=3D"BACKGROUND-COLOR: #ffffff" SIZE=3D2=
 FAMILY=3D"SANSSERIF" FACE=3D"Arial" LANG=3D"0"><BR>
<BLOCKQUOTE TYPE=3DCITE style=3D"BORDER-LEFT: #0000ff 2px solid; MARGIN-LEFT=
: 5px; MARGIN-RIGHT: 0px; PADDING-LEFT: 5px">These functions shall fail if:<=
BR>
<BR>
Domain=A0Error:</BLOCKQUOTE><BR>
</FONT><FONT  COLOR=3D"#000000" style=3D"BACKGROUND-COLOR: #ffffff" SIZE=3D3=
 FAMILY=3D"SERIF" FACE=3D"Georgia" LANG=3D"0"><BR>
</FONT><FONT  COLOR=3D"#000000" style=3D"BACKGROUND-COLOR: #ffffff" SIZE=3D2=
 FAMILY=3D"SANSSERIF" FACE=3D"Arial" LANG=3D"0"><BR>
<BLOCKQUOTE TYPE=3DCITE style=3D"BORDER-LEFT: #0000ff 2px solid; MARGIN-LEFT=
: 5px; MARGIN-RIGHT: 0px; PADDING-LEFT: 5px">The <I>x</I> argument is =B1Inf=
, or the <I>y</I> argument is =B10 and the other argument is non-NaN. If the=
 integer expression (math_errhandling &amp; MATH_ERRNO) is non-zero, then <I=
>errno</I> shall be set to [EDOM]. If the integer expression (math_errhandli=
ng &amp; MATH_ERREXCEPT) is non-zero, then the invalid floating-point except=
ion shall be raised.</BLOCKQUOTE><BR>
<BR>
MATH_ERRNO, MATH_ERREXCEPT &amp; math_errhandling are described in <BR>
<BR>
</FONT><FONT  COLOR=3D"#0000ff" style=3D"BACKGROUND-COLOR: #ffffff" SIZE=3D3=
 FAMILY=3D"SERIF" FACE=3D"Georgia" LANG=3D"0"><A HREF=3D"http://www.opengrou=
p.org/onlinepubs/007904975/basedefs/math.h.html">http://www.opengroup.org/on=
linepubs/007904975/basedefs/math.h.html</A></FONT><FONT  COLOR=3D"#000000" s=
tyle=3D"BACKGROUND-COLOR: #ffffff" SIZE=3D2 FAMILY=3D"SANSSERIF" FACE=3D"Ari=
al" LANG=3D"0"><BR>
</FONT><FONT  COLOR=3D"#000000" style=3D"BACKGROUND-COLOR: #ffffff" SIZE=3D3=
 FAMILY=3D"SERIF" FACE=3D"Georgia" LANG=3D"0"><BR>
No official decision has been made on how errors are to be handled, to the b=
est of my knowledge.<BR>
<BR>
My approach is, "more is better."=A0 So, all of the above went into the new=20=
remainder functions except for testing </FONT><FONT  COLOR=3D"#000000" style=
=3D"BACKGROUND-COLOR: #ffffff" SIZE=3D2 FAMILY=3D"SANSSERIF" FACE=3D"Arial"=20=
LANG=3D"0">(math_errhandling &amp; MATH_ERRNO) </FONT><FONT  COLOR=3D"#00000=
0" style=3D"BACKGROUND-COLOR: #ffffff" SIZE=3D3 FAMILY=3D"SERIF" FACE=3D"Geo=
rgia" LANG=3D"0">or </FONT><FONT  COLOR=3D"#000000" style=3D"BACKGROUND-COLO=
R: #ffffff" SIZE=3D2 FAMILY=3D"SANSSERIF" FACE=3D"Arial" LANG=3D"0">(math_er=
rhandling &amp; MATH_ERREXCEPT).</FONT><FONT  COLOR=3D"#000000" style=3D"BAC=
KGROUND-COLOR: #ffffff" SIZE=3D3 FAMILY=3D"SERIF" FACE=3D"Georgia" LANG=3D"0=
">=A0 That is, when a domain error occurs, errno is always set to EDOM and t=
he invalid floating-point exception is always raised.&nbsp; Requirements for=
 other functions vary.<BR>
<BR>
Is this the preferred approach? =A0 If it isn't, what is?<BR>
<BR>
<BR>
<BR>
KB Williams</FONT></HTML>

--part1_27.4950dd26.2cbd8b44_boundary--

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019