Why is MATLAB displaying 1.0000 when I do 1+eps?

437 Views Asked by At

If I do the following in MATLAB:

y = 1+eps

I get the following output:

1.000000000000000

Why is it not displaying the 'eps' portion that I added to '1' and stored in y? Is this a limitation of matlab, where although it can store 1+eps, it cannot display it or am I totally misunderstanding 'eps'?

2

There are 2 best solutions below

2
On BEST ANSWER

Eps = 2.220446049250313E-16, or Eps = .0000000000000002220....

Notice how Eps has 15 zeros and then its significant digits. Well what Matlab is displaying is up to 15 decimal places. When adding 1 and Eps only the 15 0's that were added are displayed.

0
On

You can use format long to get 15 digits, although I'm not sure if that is enough the number in question is very small.

also see the documentation:

http://mathworks.com/help/matlab/matlab_prog/display-format-for-numeric-values.html

http://mathworks.com/help/matlab/ref/format.html