[Numpy-discussion] arange and floating point arguments
Charles R Harris
charlesr.harris@gmail....
Fri Sep 14 19:21:48 CDT 2007
On 9/14/07, lorenzo bolla <lbolla@gmail.com> wrote:
>
> this is really annoying.
> Matlab handles the "ceil" weirdness quite well, though.
>
> --------------------------------------------------------------
>
> >> ceil(0.6/0.1)
>
> ans =
>
> 6
>
> >> ceil((0.4+0.2)/0.1)
>
> ans =
>
> 7
>
> >> 0:0.1:0.6
>
> ans =
>
> 0 1.000000000000000e-001
> 2.000000000000000e-001 3.000000000000000e-001 4.000000000000000e-001
> 5.000000000000000e-001 6.000000000000000e-001
>
> >> 0:0.1:(0.4+0.2)
>
> ans =
>
> 0 1.000000000000000e-001
> 2.000000000000000e-001 3.000000000000000e-001 4.000000000000001e-001
> 5.000000000000001e-001 6.000000000000001e-001
>
Well, in Matlab the end point is specified and the result of the division is
probably rounded, so in order to have problems you might need to use
something like .55 as the endpoint. In Numpy's arange an upper bound is used
instead, so roundoff is a problem, but the 5.5 case would be handled easily.
Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/numpy-discussion/attachments/20070914/3b723d00/attachment.html
More information about the Numpy-discussion
mailing list