IF statement confusion

darryaz

Registered User.
Local time
Today, 09:22
Joined
Nov 3, 2011
Messages
13
I have a situation where ideally I'd like to use the statement:

if A = B then C

Unfortunately, A and B are the result of calculations so are often carried out to many decimal places and not exactly equal. However for my purposes they are.

Would it be better to try rounding A and B when they are created or can I create an if/then statement where C is the outcome if the values of A and B are within .01 (either positive or negative) of each other?
 
If you only care about comparing the integer portion of the numbers you can use the Fix or Int functions to remove the fractional portion (see the help file if you want to know the difference between Int and Fix). Example;

IIf(Fix([A]) = Fix(), [C], [SomeOtherValue])
 
Do not use rounding - especially the Access function Round, which uses banker's rounding (look it up on Allen Browne's site). To compare floating-point numbers use your interval method,

Abs(A-B)< someSmallNumber => A=B
 

Users who are viewing this thread

Back
Top Bottom