Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

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

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.

Contact us