Floating point comparisons
[Utilities]


Defines

#define EQ(A, B)   ((lrint(A*PRECISION))==(lrint(B*PRECISION)))
#define GT(A, B)   ((lrint(A*PRECISION))>(lrint(B*PRECISION)))
#define GTE(A, B)   ((lrint(A*PRECISION))>=(lrint(B*PRECISION)))
#define LT(A, B)   ((lrint(A*PRECISION))<(lrint(B*PRECISION)))
#define LTE(A, B)   ((lrint(A*PRECISION))<=(lrint(B*PRECISION)))
#define PRECISION   100000.0

Detailed Description

Macros for comparing floating point numbers. It's a troublesome limitation of C and C++ that floating point comparisons are not very accurate. These macros multiply their arguments by a large number before comparing them, to improve resolution.

Define Documentation

#define EQ ( A,
 )     ((lrint(A*PRECISION))==(lrint(B*PRECISION)))

TRUE iff A and B are equal to within PRECISION

Referenced by stg_matrix_lines().

#define GT ( A,
 )     ((lrint(A*PRECISION))>(lrint(B*PRECISION)))

TRUE iff A is greater than B, subject to PRECISION

Referenced by itl_first_matching(), itl_wall_distance(), and stg_matrix_lines().

#define GTE ( A,
 )     ((lrint(A*PRECISION))>=(lrint(B*PRECISION)))

TRUE iff A is greater than or equal B, subject to PRECISION

Referenced by itl_first_matching(), itl_wall_distance(), stg_cell_locate(), and stg_matrix_lines().

#define LT ( A,
 )     ((lrint(A*PRECISION))<(lrint(B*PRECISION)))

TRUE iff A is less than B, subject to PRECISION

Referenced by itl_first_matching(), itl_wall_distance(), stg_cell_locate(), and stg_matrix_lines().

#define LTE ( A,
 )     ((lrint(A*PRECISION))<=(lrint(B*PRECISION)))

TRUE iff A is less than or equal to B, subject to PRECISION

#define PRECISION   100000.0

Precision of comparison. The number of zeros to the left of the decimal point determines the accuracy of the comparison in decimal places to the right of the point. E.g. precision of 100000.0 gives a comparison precision of within 0.000001


Generated on Wed Jun 3 23:12:29 2009 for Stage by  doxygen 1.5.9