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:
Bug when doing simple subraction/multiplication

Subject: Bug when doing simple subraction/multiplication

From: lisett

Date: 24 Nov, 2010 01:05:34

Message: 1 of 3

I am currently running MATLAB R2010a and I am getting the following bug in the command window.

>> b = 6.245

b = 6.245000000000000

>> b = b- 6

b = 0.245000000000000

>> b = b *10

b = 2.450000000000001

>> b = b *10

b = 24.500000000000011

>> b = b *10

b = 2.450000000000001e+002


This is not an isolated problem to the numbers given in this example.

Where are these extra values coming from? And more importantly how can I do this type of shifting without these extra values?

Subject: Bug when doing simple subraction/multiplication

From: lisett

Date: 24 Nov, 2010 01:19:03

Message: 2 of 3

accidently posted this twice. Sorry

Subject: Bug when doing simple subraction/multiplication

From: Matt Fig

Date: 24 Nov, 2010 01:24:04

Message: 3 of 3

Floating point arithmetic, welcome to it!

http://matlab.wikia.com/wiki/FAQ#Why_is_0.3_-_0.2_-_0.1_.28or_similar.29_not_equal_to_zero.3F

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