On Sat, May 1, 2010 at 3:36 PM, Gökhan Sever <gokhanse...@gmail.com> wrote:
> Hello, > > Is "b" an expected value? I am suspecting another floating point arithmetic > issue. > > I[1]: a = np.arange(1.6, 1.8, 0.1, dtype='float32') > > I[2]: a > O[2]: array([ 1.60000002, 1.70000005], dtype=float32) > > I[3]: b = np.arange(1.7, 1.8, 0.1, dtype='float32') > > I[4]: b > O[4]: array([ 1.70000005, 1.79999995], dtype=float32) > > A bit conflicting with the np.arange docstring: > > "* Values are generated within the half-open interval ``[start, stop)`` > (in other words, the interval including `start` but excluding `stop`). > *" > > Thanks. > > -- > Gökhan > Fair enough explanations to use np.linspace instead. What was confusing me above while a[1] and b[0] shows 1.70000005 only "b" steps up to 1.79999995 which "a" can't. The following is another surprise output: I[5]: c = np.arange(0.4, 0.5, 0.1, dtype='float32') I[6]: c O[6]: array([ 0.40000001], dtype=float32) Anyways, a Slashdotter might have seen me asking these questions. I will go read What Every Programmer Should Know About Floating-Point Arithmetic<http://developers.slashdot.org/story/10/05/02/1427214/What-Every-Programmer-Should-Know-About-Floating-Point-Arithmetic>article. -- Gökhan
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion