I realize this is a somewhat vague question so I'll do my best. If I have a number like n = 0.783325849821429
, is there a way to display even more decimal places? This was produced with format long. The problem is that I'm doing error estimate calculations with sine and there comes a point where the estimation is so close to the actual value of sine that MATLAB calculates the error as 0, even though it's not possible that the estimation is completely accurate. There's always error, it's just too small for MATLAB to recognize. Is there a way to make MATLAB consider more decimal places?
You can always ask for more digits using formatted strings
fprintf(1, 'n = %.20f\n', n ); % print with 20 digits after the decimal point
However there is a limit to the precision of stored numbers in floating point.
You can test the machine precision using eps
eps( n )
If your estimate error is smaller than eps
than your estimate is within machine precision and cannot be measured.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With