Comparing Numbers w/ Decimal Places

Jonathan Kok

Registered User.
Local time
Today, 16:47
Joined
Jan 27, 2000
Messages
116
OK, I've got a form in which I need to compare two fields and ensure that the numbers are the same. One field is a standard, unbound text box with Currency formatting. The second is in a subform, tied to a table, with the Number format in the table, and currency formatting on the field. If I use a decimal in the two boxes, the numbers will not equal each other. For example, if I type 11.35 in the unbound text box, and 11.35 in the bound box, it tells me the numbers do not equal each other.

I realize why this is, ie, stupid computers can't store decimal places properly (blame it on Intel and their crappy floating point decimal
smile.gif
). And I've found a way around it, in that I set the root table's number field to decimal on a scale of 2 (it WAS set to single). I'm just curious as to whether there's a better way to do this, or is this the correct way?

Thanks!
 
instead of comparing Bound and Unbound, compare (Int((100 * Bound) + 0.5))/100 with (Int((100 * Unbound) + 0.5))/100.
 
My 2 cents:

When I know I will need to do precise calculation/comparisons, I always define the fields involved as currency. Currency use a special -no floating point- format to allow accuracy needed namely for accounting purpose.

Alex

[This message has been edited by Alexandre (edited 03-12-2002).]

[This message has been edited by Alexandre (edited 03-12-2002).]
 

Users who are viewing this thread

Back
Top Bottom