NetBSD 6.1.5 doesn't have ldexpl in math.h
Mark Atwood
fallenpegasus at gmail.com
Wed Sep 13 23:15:10 UTC 2017
We could just grab from NetBSD7. Or if we know it's an IEEE754 float, just
do the direct bit ops. Or the direct fp cpu op.
..m
On Wed, Sep 13, 2017 at 4:05 PM Gary E. Miller via devel <devel at ntpsec.org>
wrote:
> 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 <(541)%20382-8588>
>
> Veritas liberabit vos. -- Quid est veritas?
> "If you can’t measure it, you can’t improve it." - Lord Kelvin
> _______________________________________________
> devel mailing list
> devel at ntpsec.org
> http://lists.ntpsec.org/mailman/listinfo/devel
--
Mark Atwood
http://about.me/markatwood
+1-206-604-2198 Mobile & Signal
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ntpsec.org/pipermail/devel/attachments/20170913/405de9f9/attachment.html>
More information about the devel
mailing list