This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: exp sets the errno to ERANGE error .
Thank you Nagy,
Standard states that "errno acquires the value ERANGE is
implementation-defined" .
So ,its not mandate the setting the errno for uflow..
~Umesh
On Tue, May 7, 2019 at 3:07 PM Szabolcs Nagy <Szabolcs.Nagy@arm.com> wrote:
>
> On 07/05/2019 08:51, Umesh Kalappa wrote:
> > Hi everyone ,
> >
> > we have situations ,where the following program sets the errno to
> > 34(range error) in the version 2.28
> >
> > $cat test.c
> > int main() {
> > printf("errno %d\n", errno);
> > printf("%f\n", exp(-1421.0));
> > printf("errno %d\n", errno);
> > }
> >
> > according the C11 standard the exp should not set the errno to ERANGE
> > when it underflow to zero .
> >
> > so we think that glibc (atleast 2.28) is not consistent with the C
> > standard and any comments regrading the same .
>
> the c standard allows ERANGE for uflow.
>
> "If the result underflows, the function returns an
> implementation-defined value whose magnitude is no
> greater than the smallest normalized positive number
> in the specified type; if the integer expression
> math_errhandling & MATH_ERRNO is nonzero, whether
> errno acquires the value ERANGE is implementation-defined;"
>
> http://port70.net/~nsz/c/c11/n1570.html#7.12.1p6
>
> glibc documents its behaviour as
>
> "When underflow occurs, the underflow exception is raised,
> and zero (appropriately signed) or a subnormal value, as
> appropriate for the mathematical result of the function and
> the rounding mode, is returned. errno may be set to ERANGE,
> but this is not guaranteed; it is intended that the GNU C
> Library should set it when the underflow is to an appropriately
> signed zero, but not necessarily for other underflows."
>
> https://www.gnu.org/software/libc/manual/html_node/Math-Error-Reporting.html
>
> >
> > Thank you and looking forward for any suggestions / comments.
> > ~Umesh
> >
>