=round - Excel Rounding Problem

respree

Active Member
Joined
Apr 14, 2003
Messages
258
Does anyone know if Excel has a rounding problem?

I am taking a number, dividing it by 1000 and rounding it to 1 decimal point.

i.e. Cell A1 - 41349
Cell A2 - =round(a1/1000),1)

formula "appears to" correctly produces 41.4 as the answer

Cell B1 - 49199
Cell B2 - =round(B1/1000),1)

formula "appears to" correctly produces 49.2 as the answer

However, A2 minus B2 (formula in C2) doesn't produce the expected (7.8)

Its very close, but the actual answer when displayed in 14 decimal positions is (-7.80000000000001) - note the "1" in the 14th position.

This may seem like trivial rounding difference, but the reason I'm asking is because I'm trying to validate the answer by matching it against Cell C2, which has the formula: if(c2=-7.8,"true","false")

The answer 'should be' true, but instead its saying its false because of the 1 in the 14th position of the answer.

Is this a design flaw with Excel or does anybody know a way around this.

Thanks very much for your input.
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
While the references you got about floating point numbers in digital computers are relevant and worth understanding...
respree said:
Does anyone know if Excel has a rounding problem?

I am taking a number, dividing it by 1000 and rounding it to 1 decimal point.

i.e. Cell A1 - 41349
Cell A2 - =round(a1/1000),1)

formula "appears to" correctly produces 41.4 as the answer
The correct answer is 41.3, which is what I get with XL2002SP1.
 
Upvote 0
Hi tusharm: Yes, I agree. I'm afraid I made a typo on my question.

I figured a workaround the computational flaw, so no need for further responses.

instead of =if((a2-b2)=c2,"true","false")

I said:

=if((a2-b2)-c2<.001,"true","false") (i.e. a virtual match)

assuming the computational flaw is 'very' insignificant.
 
Upvote 0
Barry Katcher said:
Respree, no need for a work-around. See my suggestion above.
which is a workaround. Isn't it? {g}

As far as the 'workaround' of testing that a result is less than a threshold, it is the *standard* way of working with floating point numbers. Though, typically, the threshold is of the magnitude of 1e-6 or 1e-8 or even smaller.
 
Upvote 0
To make your fix more universal, you might want to consider taking the absolute value of the result rather than the actual result. It is possible that the result might be -1E-14 rather than 1E-14.
 
Upvote 0
Tushar, I thought of that a half-second after I clicked the "Submit" button, but said "Oh, well, this will just give someone on the board an opportunity to embarrass me." :LOL:
 
Upvote 0
ALERT!!!

Can anyone help with my gradesheet workbook. I am having serious problems with rounding. Sometimes the grade averages are not rounding when they should up to the nearest whole number. Many times I see this in my grade workbook that is causing many problems. I cannot use the 'Set precision as displayed' because it affects all other grades with inaccurate grades. It seems to have problems when it needs to round numbers like 85.5, 78.5, 91.5, etc. Please help. These are simple grades and not big numbers.

Has anyone seen this?
 
Upvote 0

Forum statistics

Threads
1,214,944
Messages
6,122,391
Members
449,080
Latest member
Armadillos

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top