NetBSD 6.1.5 doesn't have ldexpl in math.h

Gary E. Miller gem at rellim.com
Wed Sep 13 23:05:30 UTC 2017


Yo Mark!

On Wed, 13 Sep 2017 22:31:31 +0000
Mark Atwood via devel <devel at ntpsec.org> wrote:

> How much complexity would it add to add the missing fp functions in
> the same way the strlcpy function is?

I think all we need for NetBSD 6.1 is ldexpl().

Here is one way, a very slow way, to do it:

long double ldexpl(long double value, int e)
{
  if (value == 0 || value == INFINITY || value == -INFINITY || value != value)
  {
    // Return +0.0/-0.0, +INF/-INF and NaN as-is
  }
  else
  {
    while (e > 0)
      value = value * 2, e--;
    while (e < 0)
      value = value * 0.5f, e++; // won't round denormals correctly
  }
  return value;
}

Ripped from:

https://github.com/alexfru/SmallerC/blob/master/v0100/srclib/ldexp.c

NTPsec only uses 32 and -32 values for 'e', so some simplification
possible.

The INF tests should likely be replaced with isfinite().

RGDS
GARY
---------------------------------------------------------------------------
Gary E. Miller Rellim 109 NW Wilmington Ave., Suite E, Bend, OR 97703
	gem at rellim.com  Tel:+1 541 382 8588

	    Veritas liberabit vos. -- Quid est veritas?
    "If you can’t measure it, you can’t improve it." - Lord Kelvin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <https://lists.ntpsec.org/pipermail/devel/attachments/20170913/a77b7251/attachment.bin>


More information about the devel mailing list