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@ntpsec.org> wrote: > Yo Mark! > > On Wed, 13 Sep 2017 22:31:31 +0000 > Mark Atwood via devel <devel@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 > g...@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@ntpsec.org > http://lists.ntpsec.org/mailman/listinfo/devel -- Mark Atwood http://about.me/markatwood +1-206-604-2198 Mobile & Signal
_______________________________________________ devel mailing list devel@ntpsec.org http://lists.ntpsec.org/mailman/listinfo/devel