help-octave
[Top][All Lists]

Re: Uniform partition of an interval

 From: W. Peters Subject: Re: Uniform partition of an interval Date: Wed, 17 May 2000 11:21:33 -0700 (PDT)

```I tried this in MATLAB:

>> 1.8 + 0.05*2 - 1.9

ans =

2.2204e-16

>> 1.8:0.05:1.9

ans =

1.8000    1.8500    1.9000

On Wed, 17 May 2000, etienne grossmann wrote:

> Date: Wed, 17 May 2000 10:27:45 +0100 (WEST)
> Subject: Re: Uniform partition of an interval
> Resent-Date: Wed, 17 May 2000 04:30:35 -0500 (CDT)
>
>
>   Hello,
>
>
> #  From: Francesco Potorti` <address@hidden>
> #  To: Octave users list <address@hidden>
> #
> #     What is the MAIN reason that 1.8:0.05:1.9 produces [1.8000 1.8500]
> #     and not [1.8000 1.8500 1.9000]?
> #
> #  Finite precision of the machine's number representation.
>
>   Indeed, with 2.1.19,
>
> octave:3> 1.8 + 0.05*2 - 1.9
> ans =  2.2204e-16
>
>   So 1.8 + 0.05*2 is strictly greater than 1.9. Not a bug, but the
> effect of floating point precision.
>
>
>   Cheers,
>
>
>   Etienne
>
>
>
> -----------------------------------------------------------------------
> Octave is freely available under the terms of the GNU GPL.
>
> Octave's home on the web:  http://www.che.wisc.edu/octave/octave.html
> How to fund new projects:  http://www.che.wisc.edu/octave/funding.html
> Subscription information:  http://www.che.wisc.edu/octave/archive.html
> -----------------------------------------------------------------------
>
>

------------------------------------------------
William Peters
Department of Bioengineering
University of Washington
Box 357962
Seattle, WA 98195
(206)543-6442
------------------------------------------------

-----------------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.che.wisc.edu/octave/octave.html
How to fund new projects:  http://www.che.wisc.edu/octave/funding.html
Subscription information:  http://www.che.wisc.edu/octave/archive.html
-----------------------------------------------------------------------

```