BUG: improve log2 windows compiler fallback of log2

Fallback (similar to python3.4 math.log2) provides int(log(2**i)) == i
in default rounding mode.
Non-default rounding modes not tested but if it does not work we are at
least not worse than python.
Closes gh-4787
We could just merge it and see whether anyone complains at beta time. One
over-strict test isn't a showstopper.


On Sat, Jun 7, 2014 at 6:09 PM, Charles Harris <notifications@github.com>
wrote:

> In numpy/core/tests/test_umath.py:
>
> > @@ -189,6 +190,27 @@ def test_log2_values(self) :
> >              yf = np.array(y, dtype=dt)
> >              assert_almost_equal(np.log2(xf), yf)
> >
> > +    def test_log2_ints(self):
> > +        # a good log2 implementation should provide this,
> > +        # might fail on OS with bad libm
> > +        for i in range(1, 65):
> > +            v = np.log2(2.**i)
> > +            assert_equal(int(v), i)
>
> Note that int truncates, it doesn't round. The v == i check works for gcc
> on linux, but as you say, might be a bit strict for some libraries.
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/numpy/numpy/pull/4790/files#r13520374>.
>



-- 
Nathaniel J. Smith
Postdoctoral researcher - Informatics - University of Edinburgh
http://vorpus.org