-, , vpa . " ", " " :
>> disp(vpa(sym('0.135'),2))
0.14
>> disp(vpa(sym('0.125'),2))
0.12
>> disp(vpa(sym('0.115'),2))
0.11
Octave Matlab:
>> disp(vpa(sym('0.135'),2))
0.14
>> disp(vpa(sym('0.125'),2))
0.13
>> disp(vpa(sym('0.115'),2))
0.11
, - .
W . . N (, ) , A = 1 , , , A = 0 . .

. W = 3, Matlab.
N = 0, A = 0: .
>> disp(vpa(sym('0.12345'),3)) % works: first 3 digits are correct
0.123
N = 0, A = 1: , W = 3 :
>> disp(vpa(sym('0.12378'),3)) % doesn't work
0.124
>> disp(vpa(sym('0.12378'),4)) % works: first 3 digits are correct
0.1238
N > 0, A = 0: N :
>> disp(vpa(sym('0.123994'),3)) % doesn't work
0.124
>> disp(vpa(sym('0.123994'),4)) % doesn't work
0.124
>> disp(vpa(sym('0.123994'),5)) % works: first 3 digits are correct
0.12399
N > 0, A = 1: N+1 :
>> disp(vpa(sym('0.123997'),3)) % doesn't work
0.124
>> disp(vpa(sym('0.123997'),4)) % doesn't work
0.124
>> disp(vpa(sym('0.123997'),5)) % doesn't work
0.124
>> disp(vpa(sym('0.123997'),6)) % works: first 3 digits are correct
0.123997
E , vpa vpa , W . E = N + A
N A . , , E = 1 E 0. , E . E = max(1, N+A); , , , ( 1 ).
, , , . ( ).
s = sym('pi'); % number in symbolic form
W = 79; % number of wanted digits
E = 0; % initiallize
done = false;
while ~done
E = E+1;
x = char(vpa(s, W+E));
y = regexprep(x, '^[+-]?0*|\.0*', ''); % remove sign, leading zeros,
% decimal point and zeros right after the point; if present
y = regexprep(y, '\D.*$', ''); % remove exponent and imaginary unit,
% if present
num_digits = numel(y); % get number of significant digits in x:
done = num_digits==W+E && x(end)~='0'; % the second condition is only
% required in Octave, but it doesn't harm to keep it in Matlab too
end
c = find(~ismember(x, ['0':'9' '+-.']), 1);
if c % there is an exponent or/and imaginary unit
result = [x(1:c-1-E) x(c:end)]; % discard last E digits before
% exponent or imaginary unit
else
result = x(1:end-E); % discard last E digits
end