What is wrong with this code for finding out the number of significant digits after decimal?
I have created this code for finding the number of siignificant digits after decimal for Cody, but for some reason, it shows error (semantic). Can anyone please help identify why? Thank you.
The error comes when I apply:
x = [1.000 1.04 0.22 10.1; 2.05 2.33 4.1 1000.31; 5.00010 6.429 7.492 8.0]
I tried debugging, but the error comes due to 6.429 having a ‘1’ after another 11 zeroes.
Code:
function y = find_max_sigdec(x)
stop = 0;
i = 0;
if x == fix(x)
y = 0;
else
while stop == 0
x = x*10;
i = i+1;
if x == fix(x)
y = i;
stop = 1;
end
end
end
endI have created this code for finding the number of siignificant digits after decimal for Cody, but for some reason, it shows error (semantic). Can anyone please help identify why? Thank you.
The error comes when I apply:
x = [1.000 1.04 0.22 10.1; 2.05 2.33 4.1 1000.31; 5.00010 6.429 7.492 8.0]
I tried debugging, but the error comes due to 6.429 having a ‘1’ after another 11 zeroes.
Code:
function y = find_max_sigdec(x)
stop = 0;
i = 0;
if x == fix(x)
y = 0;
else
while stop == 0
x = x*10;
i = i+1;
if x == fix(x)
y = i;
stop = 1;
end
end
end
end I have created this code for finding the number of siignificant digits after decimal for Cody, but for some reason, it shows error (semantic). Can anyone please help identify why? Thank you.
The error comes when I apply:
x = [1.000 1.04 0.22 10.1; 2.05 2.33 4.1 1000.31; 5.00010 6.429 7.492 8.0]
I tried debugging, but the error comes due to 6.429 having a ‘1’ after another 11 zeroes.
Code:
function y = find_max_sigdec(x)
stop = 0;
i = 0;
if x == fix(x)
y = 0;
else
while stop == 0
x = x*10;
i = i+1;
if x == fix(x)
y = i;
stop = 1;
end
end
end
end significant digits, rounding off MATLAB Answers — New Questions