RFA: Add ! LDBL_EQ_DBL implementations of cosl, sinl and tanl
Gregory Pietsch
gpietsch@comcast.net
Tue Mar 3 19:01:00 GMT 2015
On 3/3/2015 11:48 AM, Craig Howland wrote:
>
> On 03/03/2015 09:45 AM, Gregory Pietsch wrote:
>> Here's my attempt at all of the functions in the background of this.
>> Feel free to criticize and carve it up like a Thanksgiving turkey. --
>> Gregory
>>
> In a quick look at it, I don't see where the _Classify function
> properly handles the Intel 80-bit long double format, which has the
> fixed msb set in the significand--which needs to be ignored in the
> INF/NAN check. If it does, could you point it out to me?
I knew there was something wrong with that. Thanks for pointing that
out! A correction is attached.
>
> By the way, I have almost all of the long double functions done, but
> am still probably a couple of weeks away from getting the last details
> done to be able to submit the first piece. The strtold that I
> mentioned a couple of weeks ago is the first I am working towards, but
> it requires some infrastructure that I have to resolve, and time to
> work on it has been hard to come by. Once I get that, I'm planning on
> putting in strtold. After that there's lots more. The stuff I have
> has been tested with Intel 80-bit (the biggest nuisance because of
> that p0 bit), as well as 128-bit on SPARC. Of course, if others get
> there first, that's OK, since I have been very pokey on it.
I think it's fun to compare implementations. I've gotten just about
everything written that doesn't require a polynomial approximation in my
implementation of the math library. Maybe we'll get better at it. -- Gregory
>
> Craig
>
-------------- next part --------------
/* fpclassify.c - classify real-floating type
AUTHOR: Gregory Pietsch
DESCRIPTION:
The functionality described on this reference page is aligned with the ISO
C Standard. Any conflict between the requirements described here and the
ISO C Standard is unintentional. This volume of POSIX.1-2008 defers to the
ISO C Standard.
The fpclassify() macro shall classify its argument value as NaN, infinite,
normal, subnormal, zero, or into another implementation-defined category.
First, an argument represented in a format wider than its semantic type is
converted to its semantic type. Then classification is based on the type of
the argument.
RETURN VALUE:
The fpclassify() macro shall return the value of the number classification
macro appropriate to the value of its argument.
ERRORS:
No errors are defined.
*/
#include "xmath.h"
static int
_Classify (unsigned char *x, size_t size)
{
unsigned short hdr, mask, f;
size_t ebits, i;
ebits = _Get_ebits(size);
hdr = x[_Byte (0, size)];
hdr <<= 8;
hdr |= x[_Byte (1, size)];
mask = ~(~0 << ebits) << (15 - ebits);
f = (hdr & ~(~0 << (15 - ebits)));
hdr &= mask;
f |= (size == 10) ? x[_Byte (2, size)] & ~0x80 : x[_Byte (2, size)];
for (i = 3; i < size; ++i)
f |= x[_Byte (i, size)];
if (hdr == 0)
return f ? FP_SUBNORMAL : FP_ZERO;
else if (hdr == mask)
return f ? FP_NAN : FP_INFINITE;
else
return FP_NORMAL;
}
int
_Fpclassify (double x)
{
return _Classify ((unsigned char *) (&x), sizeof (double));
}
int
_Fpclassifyf (float x)
{
return _Classify ((unsigned char *) (&x), sizeof (float));
}
int
_Fpclassifyl (long double x)
{
return _Classify ((unsigned char *) (&x), sizeof (long double));
}
/* END OF FILE */
More information about the Newlib
mailing list