FLOATS_EQUAL
The purpose of this function is to compare two floating-point values or arrays to determine if the values or arrays are equal. Arrays are equal if they have the same number of elements, and each element is equal. To learn why determing if floats are equal is hard (and probably not done correctly in this program), please read the following article:: http://www.cygnus-software.com/papers/comparingfloats/comparingfloats.htm
FANNING SOFTWARE CONSULTING David Fanning, Ph.D. 1645 Sheely Drive Fort Collins, CO 80526 USA Phone: 970-221-0438 E-mail: david@idlcoyote.com Coyote's Guide to IDL Programming: http://www.idlcoyote.com
Utilities
result = FLOATS_EQUAL(array_1, array_2)
array_1 Any single or double precision value or array. Required parameter. array_2 Any single or double precision value or array. Required parameter.
ULP UNIT in the LAST PLACE. It is the gap or difference between two floating point numbers in the last digit that can distinguish the two numbers. Must be a positive integer. Set to 1 by default. Set to a larger value if you suspect accumulative round-off errors in your arrays.
result Set to 1 if the arrays are equal, which means that the arrays have the same number of elements and each element is equal to the same element in the other array. Set to 0 if the arrays are not equal.
None.
IDL> a = Findgen(11) IDL> b = Findgen(11) IDL> Print, Floats_Equal(a,b) 1 IDL> b[4] = b[4] + 0.0001 IDL> Print, Floats_Equal(a,b) 0
None.
Written by: David W. Fanning, 29 August 2007. Fixed a problem when using large numbers with the TOTAL command by setting the INTEGER keyword. 22 June 2011. DWF. Made sure ULP value is an integer.