Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default numeric calculation in logical formula

cell a1 = 1.2999, cell b1=1.3000

I want a "if" formula like this:

=if(((b1-a1)=0.0001),true,false)...it seems in the logical formula, the
calculation is ignored and it always gives a false result.

Can anybody help how to do it??

Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 221
Default numeric calculation in logical formula

Interesting. When I do b1-a1 (only), I get this result:
0.0000999999999999890


*******************
~Anne Troy

www.OfficeArticles.com
www.MyExpertsOnline.com


"Chris Vermaak" <Chris wrote in message
...
cell a1 = 1.2999, cell b1=1.3000

I want a "if" formula like this:

=if(((b1-a1)=0.0001),true,false)...it seems in the logical formula, the
calculation is ignored and it always gives a false result.

Can anybody help how to do it??

Thanks



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 133
Default numeric calculation in logical formula

Yea there is a wierd rounding issue there. This works for me:

=IF(ROUND(B1-A1,3)=0.001,TRUE,FALSE)

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default numeric calculation in logical formula

You will be hard pressed to make that comparison because of the way the IEEE
standard dictates the storage of floating point numbers.

If you want to know that it is exactly a difference of .00001

you might use an approach like:

=IF(ABS(ABS(B1-A1)-0.0001) < 0.00001,TRUE,FALSE)

you would need to play with it to be as restrictive as you want. In any
event, just like you can't eactly represent 1/3 in decimal, there are many
decimal numbers that can't be exactly represented in binary.

This characterstic isn't unique to Excel:

http://support.microsoft.com/default...kb;en-us;48606
XL: Comparison of Values Does Not Return Correct Result

http://support.microsoft.com/default...kb;en-us;78113
XL: Floating-Point Arithmetic May Give Inaccurate Results

http://support.microsoft.com/default...kb;en-us;42980
(Complete) Tutorial to Understand IEEE Floating-Point Errors


http://support.microsoft.com/default...b;en-us;165373
Rounding Errors In Visual Basic For Applications

http://support.microsoft.com/default...kb;en-us;69333
HOWTO: Work Around Floating-Point Accuracy/Comparison Problems

--
Regards,
Tom Ogilvy

"Chris Vermaak" <Chris wrote in message
...
cell a1 = 1.2999, cell b1=1.3000

I want a "if" formula like this:

=if(((b1-a1)=0.0001),true,false)...it seems in the logical formula, the
calculation is ignored and it always gives a false result.

Can anybody help how to do it??

Thanks



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default numeric calculation in logical formula


Hi Everyone,

Thanks for all the responses. It seems the issue hereis going into decimals.
I'm goint to try the suggestions. Another option I'm considering is to have
a secondary cell where c1=a1*10000. which means the value goes to 2999 and
not1.2999. This will then take the value for the sake of the logical formula
out of decimals, thus 12999 and 13000. Will keep posted.

Thanks again



"Chris Vermaak" wrote:

cell a1 = 1.2999, cell b1=1.3000

I want a "if" formula like this:

=if(((b1-a1)=0.0001),true,false)...it seems in the logical formula, the
calculation is ignored and it always gives a false result.

Can anybody help how to do it??

Thanks



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default numeric calculation in logical formula

If you multiply the value with 10000 in a secondary cell and use the
secondary cells for the logical fromula is works. Thanks again

ChrisThanks
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Numeric calculation Flying_Dutcman Excel Worksheet Functions 8 July 5th 10 06:26 AM
non-numeric in a calculation Albert.Harmse[_2_] Excel Worksheet Functions 1 January 5th 10 04:44 AM
Substitute a numeric value for a text value in a calculation. Jeff Excel Discussion (Misc queries) 11 May 16th 07 07:48 PM
Using Logical Function in Pivot Calculation Mike G Excel Worksheet Functions 0 February 3rd 06 03:59 PM
pivot table logical calculation Spencer Hutton Excel Worksheet Functions 0 March 8th 05 06:17 PM


All times are GMT +1. The time now is 04:58 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"