equality operator bug

Rob Mahurin rob at utk.edu
Wed Jun 10 12:14:45 CDT 2009


On Jun 10, 2009, at 12:47 PM, Gonzalez, Jose A Capt USAF AFRl/RYAR  
wrote:
> Description:
> -----------
>
>   * At times, the equality operator returns '0' when it should  
> return '
> 1'.  Of course, this doesn't happen all the time.  Only some numbers
> cause the error.  This same problem causes find(x == constant ) to  
> also
> work improperly.
>
> Repeat-By:
> ---------
>
>   * A = 1.48 +.001
>       returns A = 1.4810
>
>     A == 1.481
>       returns 0 (false)


These expressions return different floating-point values:

 > printf("%0.19f\n", [ 1.48 + 0.001 , 1.481 ] )
1.4809999999999998721
1.4810000000000000941

so "==" returns the correct answer.

Rob

-- 
Rob Mahurin
Department of Physics and Astronomy
University of Tennessee 		865 207 2594
Knoxville, TN 37996 			rob at utk.edu





More information about the Bug-octave mailing list