[Cfp-interest 1294] Re: Next representable for a double-double

Fred J. Tydeman tydeman at tybor.com
Fri Apr 26 22:05:44 PDT 2019


On Fri, 26 Apr 2019 08:23:22 -0400 Stephen Canon wrote:
>
>This isn't quite right; it skips a value when the sign of lo flips.
>
>A simple example is ld = 1 + e/2 Your algorithm gives the next value as 1 + u(e/2), but the value halfway in between is also 
>representable in the form (1+e) - d(e/2), where "e" is 0x1.0p-52, "u( )" and "d( )" are nextup and nextdown, respectively.

Agreed.  I believe that this next version fixes that issue.

How to find next representable number for long double being a
double-double.  This is nextup(of a positive number).

long double ld = some value;
double dhi, dlo;

dhi = ld.hi + ld.lo; /* get high word with round=ties away from zero */
dlo = ld - dhi; /* get low word */
dlo = nextafter(dlo,copysign(1.0,dlo)*INFINITY); /* next representable */
ld = dhi + dlo; /* next representable after ld */


---
Fred J. Tydeman        Tydeman Consulting
tydeman at tybor.com      Testing, numerics, programming
+1 (702) 608-6093      Vice-chair of PL22.11 (ANSI "C")
Sample C99+FPCE tests: http://www.tybor.com
Savers sleep well, investors eat well, spenders work forever.



More information about the Cfp-interest mailing list