Home > Archive > Matlab > February 2007 > precission error
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
| mankei 2007-02-28, 4:19 am |
| Hi,
I have got the following problem.
K>> 1149852480.0 - 1149852399.855
ans =
80.1449999809265
The result should be 80.145.
What's wrong with that?
Are the numbers too large?
Has anybody else this problem?
Thanks for your help.
Stefan.
| |
|
|
| Nasser Abbasi 2007-02-28, 4:19 am |
|
"mankei" <no@no.com> wrote in message
news:45e53a55$0$28520$3b214f66@tunews.univie.ac.at...
> Hi,
>
> I have got the following problem.
>
> K>> 1149852480.0 - 1149852399.855
> ans =
>
> 80.1449999809265
>
> The result should be 80.145.
>
> What's wrong with that?
> Are the numbers too large?
> Has anybody else this problem?
>
> Thanks for your help.
> Stefan.
>
[color=darkred]
ans =
80.14499998092651
[color=darkred]
ans =
80.1450
[color=darkred]
Nasser
| |
| Nasser Abbasi 2007-02-28, 4:19 am |
|
"Nasser Abbasi" <nma@12000.org> wrote in message
news:cmcFh.34010$AU.29638@newsfe07.phx...[color=darkred]
>
> "mankei" <no@no.com> wrote in message
> news:45e53a55$0$28520$3b214f66@tunews.univie.ac.at...
>
>
> ans =
>
> 80.14499998092651
>
>
> ans =
>
> 80.1450
>
btw, I think my answer is not right. I think you have a lose of precission,
becuase you are subtracting 2 numbers close to each others.
I started saying that, but did not see how it would be, since with about 52
or bits for mantisa, it is more than enough for these 2 numbers.
any way, I think the problem is more likley loss of precission. Formating
just displays the numbers differently, does not afect the computation.
there is a formual that says if you have 2 normalized numbers, x,y, and x>y,
and you do x-y, then lose of bits is betwen q and p where q and p are given
by
2^-q <= 1- y/x <= 2^-p
this given about 23 bits for your numbers. that is why I did not think it
is loss of precission error at first.
any way, rule of thumb, do not subtract numbers that are close to each
others, or better yet, use Maple ;)
[color=darkred]
ans =
80.145
Nasser
|
|
|
|
|