PC Review Forums Newsgroups Microsoft Excel Microsoft Excel Crashes Subtracting gives the wrong answer!!

Reply

Subtracting gives the wrong answer!!

 
Thread Tools Rate Thread
Old 04-11-2004, 02:33 PM   #1
=?Utf-8?B?QWl0Y2g=?=
Guest
 
Posts: n/a
Default Subtracting gives the wrong answer!!


Hello all,

I'm just doing some general adding, subtracting and some "IF" formulas etc.
in a worksheet. All was going great until I got to one sum and the formula
came back with "incorrect". Now, I've tried this on another colleague's pc
as well - in case I had a wrong setting, and it came up with the same answer.
The sum is the following (try it yourself!)
5012.10-5024.70
The answer should be -12.60, which is correct, but the formula showed
incorrect. It wasn't until I pressed F2 and then F9 I saw the complete
answer - which is -12.5999999999995. I know that it probably just rounded
the answer off somehow, but how did it find the answer?? I'm only using 2
decimal numbers.

Could this be a glitch?? I've tried different numbers which end in 12.10 and
24.70, but it works fine.

I'm just wondering how many other calculations are like this???

Thanks for your time

Aitch
  Reply With Quote
Old 04-11-2004, 03:42 PM   #2
Guest
 
Posts: n/a
Default Subtracting gives the wrong answer!!

hi,
welcome to microsoft products.
I don't know why but in my 15 years(or so) that i have
been using microsoft products(excel and access mostly), i
have found that they do this perticularly in calculations.
the calculated answer should be six but you get
5.999999999999999999999...
a built in math bug of some sort.

>-----Original Message-----
>Hello all,
>
>I'm just doing some general adding, subtracting and

some "IF" formulas etc.
>in a worksheet. All was going great until I got to one

sum and the formula
>came back with "incorrect". Now, I've tried this on

another colleague's pc
>as well - in case I had a wrong setting, and it came up

with the same answer.
>The sum is the following (try it yourself!)
>5012.10-5024.70
>The answer should be -12.60, which is correct, but the

formula showed
>incorrect. It wasn't until I pressed F2 and then F9 I

saw the complete
>answer - which is -12.5999999999995. I know that it

probably just rounded
>the answer off somehow, but how did it find the answer??

I'm only using 2
>decimal numbers.
>
>Could this be a glitch?? I've tried different numbers

which end in 12.10 and
>24.70, but it works fine.
>
>I'm just wondering how many other calculations are like

this???
>
>Thanks for your time
>
>Aitch
>.
>

  Reply With Quote
Old 06-11-2004, 10:41 AM   #3
Steve Dalton
Guest
 
Posts: n/a
Default Re: Subtracting gives the wrong answer!!

It's not a bug. It's to do with the fact that floating point numbers are
stored as truncated binary representations not the truncated decimal
representations that we are accustomed to using in daily life. For example,
0.5 decimal is exactly 0.1 binary, but 0.2 decimal is a recurring decimal in
binary. You have two solutions: use the ROUND function (after adding a very
small increment to your result) or use the "precision as displayed" feature.

Steve Dalton

<anonymous@discussions.microsoft.com> wrote in message
news:37e801c4c284$dce9fbd0$a601280a@phx.gbl...
> hi,
> welcome to microsoft products.
> I don't know why but in my 15 years(or so) that i have
> been using microsoft products(excel and access mostly), i
> have found that they do this perticularly in calculations.
> the calculated answer should be six but you get
> 5.999999999999999999999...
> a built in math bug of some sort.
>
> >-----Original Message-----
> >Hello all,
> >
> >I'm just doing some general adding, subtracting and

> some "IF" formulas etc.
> >in a worksheet. All was going great until I got to one

> sum and the formula
> >came back with "incorrect". Now, I've tried this on

> another colleague's pc
> >as well - in case I had a wrong setting, and it came up

> with the same answer.
> >The sum is the following (try it yourself!)
> >5012.10-5024.70
> >The answer should be -12.60, which is correct, but the

> formula showed
> >incorrect. It wasn't until I pressed F2 and then F9 I

> saw the complete
> >answer - which is -12.5999999999995. I know that it

> probably just rounded
> >the answer off somehow, but how did it find the answer??

> I'm only using 2
> >decimal numbers.
> >
> >Could this be a glitch?? I've tried different numbers

> which end in 12.10 and
> >24.70, but it works fine.
> >
> >I'm just wondering how many other calculations are like

> this???
> >
> >Thanks for your time
> >
> >Aitch
> >.
> >



  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off