Thread Subject: I don't even know what subject this lies under. Simple question:

Subject: I don't even know what subject this lies under. Simple question:

From: Kian

Date: 28 Dec, 2008 06:55:02

Message: 1 of 3

>> 9*0.0006 - 0.0054

ans =

-8.6736e-019

MathWorks is closed until Monday. It's driving me insane. Does anyone know what's going on? The answer should be 0.

This works:

K>> (0.0006 + 9*6/10000) - 0.006

ans =

0

Any idea what's going on?

Subject: I don't even know what subject this lies under. Simple question:

From: Jiro Doke

Date: 28 Dec, 2008 07:16:04

Message: 2 of 3

"Kian " <kian.torab@utah.edu> wrote in message <gj77s6$hc9$1@fred.mathworks.com>...
> >> 9*0.0006 - 0.0054
>
> ans =
>
> -8.6736e-019
>
> MathWorks is closed until Monday. It's driving me insane. Does anyone know what's going on? The answer should be 0.
>
> This works:
>
> K>> (0.0006 + 9*6/10000) - 0.006
>
> ans =
>
> 0
>
> Any idea what's going on?

Read about floating point arithmetic:

http://www.mathworks.com/access/helpdesk/help/techdoc/matlab_prog/f2-12135.html#f2-98645
Especially,
http://www.mathworks.com/access/helpdesk/help/techdoc/matlab_prog/f2-12135.html#bqxyrhp

Here's also some technical notes on the website:

http://www.mathworks.com/support/tech-notes/1100/1108.html

Subject: I don't even know what subject this lies under. Simple question:

From: Jean-Marc Gulliet

Date: 28 Dec, 2008 07:42:22

Message: 3 of 3

Jiro Doke wrote:
> "Kian " <kian.torab@utah.edu> wrote in message <gj77s6$hc9$1@fred.mathworks.com>...
>>>> 9*0.0006 - 0.0054
>> ans =
>>
>> -8.6736e-019
>>
>> MathWorks is closed until Monday. It's driving me insane. Does anyone know what's going on? The answer should be 0.
>>
>> This works:
>>
>> K>> (0.0006 + 9*6/10000) - 0.006
>>
>> ans =
>>
>> 0
>>
>> Any idea what's going on?
>
> Read about floating point arithmetic:
>
> http://www.mathworks.com/access/helpdesk/help/techdoc/matlab_prog/f2-12135.html#f2-98645
> Especially,
> http://www.mathworks.com/access/helpdesk/help/techdoc/matlab_prog/f2-12135.html#bqxyrhp
>
> Here's also some technical notes on the website:
>
> http://www.mathworks.com/support/tech-notes/1100/1108.html

In addition, the article "What Every Computer Scientist Should Know
About Floating-Point Arithmetic", by David Goldberg, may be worth
reading or, at least, browsing.

http://docs.sun.com/source/806-3568/ncg_goldberg.html

Regards,
-- Jean-Marc

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
floating point ... Jiro Doke 28 Dec, 2008 02:20:08
arithmetics Kian 28 Dec, 2008 02:00:10
rssFeed for this Thread
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com