[PATCH 3/5] math: New generic fma implementation
Paul Zimmermann
Paul.Zimmermann@inria.fr
Tue Nov 25 18:07:27 GMT 2025
> > +static inline double converttoint64 (int64_t a)
> > +{
> > +#if !TOINT64_INTRINSICS
> > + union { int64_t x; double d; } low = {.d = 0x1.0p52};
> > +
> > + double high = (int32_t)(a >> 32) * 0x1.0p32;
> > + low.x |= a & INT64_C(0x00000000ffffffff);
> > +
> > + return (high - 0x1.0p52) + low.d;
>
> That's rather convertfromint64.
did you try using the same trick for the high part?
Something like (not tested):
union { int64_t x; double d; } high = {.d = 0x1.0p84}; // ulp(high) = 2^32
high.x |= a >> 32;
union { int64_t x; double d; } low = {.d = 0x1.0p52}; // ulp(low) = 1
low.x |= a & INT64_C(0x00000000ffffffff);
return (high - 0x1p86) + (low - 0x1p52);
Paul
More information about the Libc-alpha
mailing list