floating point calculation bug?
- From: "Kyongje Sung" <sungk@xxxxxxxxxx>
- Date: Wed, 15 Feb 2006 16:18:12 -0500
I'm having a problem in doing simple addition and subtraction with
floating numbers.
Following is the problem.
a = 17.9
b = 16.1
then,
(a - 1.8) == b
gives 0, which means that (a - 1.8) is not equal to 16.1.
If I try following, it is ok.
a = 12.9
b = 11.1
(a - 1.8) == b gives '1'.
It looks like MATLAB has a problem in dealing with decimal places.
Is this known to everyone already?
I thought this kind of problem only happens in MS product...
FYI, I tried following to solve the problem temporarily.
a = 17.9
b = 16.1
then,
round((a - 1.8)*10)/10 == b
gives correct answer, which is '1'.
I'm using Mac OS X (tiger) and MATLAB 7.1. I also tried the above
problems on PC with MATLAB7.0, it has the same problem.
K. Sung
.
- Follow-Ups:
- Re: floating point calculation bug?
- From: K. Sung
- Re: floating point calculation bug?
- From: Steven Lord
- Re: floating point calculation bug?
- From: us
- Re: floating point calculation bug?
- Prev by Date: Re: Logical OR operation without using a loop?
- Next by Date: Re: MCC, Don't get any output, but no errors eather...
- Previous by thread: 10 X 10 banded and dense matricies
- Next by thread: Re: floating point calculation bug?
- Index(es):
Relevant Pages
|
Loading