1
$\begingroup$

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'?

  • 1
    What do you get if you now evaluate `y - 1`?2017-01-13
  • 0
    Try `fprintf("%.20f\n", y)`. When outputting it probably only outputs a certain number of digits so this tells it to output $20$ digits after the decimal point.2017-01-13

2 Answers 2

3

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
    I see, but "inside" it is actually storing 1+eps then because there are enough bits to store it?2017-01-13
  • 0
    Correct. If you want Matlab to display the Epsilon part, you must have it display more digits.2017-01-13
0

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