[CF-metadata] bounds

John Caron caron at unidata.ucar.edu
Thu May 22 14:56:36 MDT 2003


Russ Rew wrote:

>John Caron wrote:
>
>  
>
>>I would prefer "equal within tolerence". if you need a definition of 
>>tolerence, i would use something like
>>     abs( (a-b)/b) < 1.0E-5
>>
>>The reason is that post processors shouldnt have to preserve floating 
>>point to the last bitter bit. ;^}
>>    
>>
>
>I disagree for a couple of reasons:
>
> - Post processors don't have to preserve floating point to the last
>   bitter bit, each one just has to be consistent in changing the same
>   floating point value to a different floating point value.  I can't
>   imagine any post processor (or other program) that would sometimes
>   change 0.66667 to 0.6666 and other times to 0.6667 (I'm just using
>   base 10 for illustration).  As long as the same processor munges
>   the same floating point value in the same way, equality tests will
>   work OK.  Some programs depend on that fact for processing missing
>   values for floating point.
>
> - Approximate comparison is more complex than 
>
>     abs( (a-b)/b) < 1.0E-5
>   
>   in case b is identically zero, and because there is no "epsilon"
>   that is always appropriate for such tests.  You can use an epsilon
>   appropriate for IEEE single precision floating point, but then you
>   can contrive cases where that would be wrong and exact equality
>   would be the only appropriate test.
>   
>I think Jonathan is right to recommend exact equality tests in this
>case.
>
>--Russ
>  
>
ok, let me give a use case:

Someone has tried to create a CF netcdf file and bungled it, by not 
getting the coordinate bounds correct. So I am going to use NcML to fix 
the problem, by adding some of the values in "by hand". Do I need to 
worry about if "1.0" is really 0.999999999999999999999999 in double ? So 
the problem is needing to match a floating point representation in 
ascii. how many significant places are needed?  From my POV, getting the 
last bits right is not needed, and could be onerous.

Obviously I didnt completely specify the tolerence above for the b = 0 
case. One could also specify a stricter tolerence for doubles.

What would be a "contrived" example where 1E-5 would not work ?  We are 
not trying to preserve numerical results in the face of complex 
algorthims, just trying to answer the question if the bounds are continuous.



More information about the CF-metadata mailing list