# I want to reduce accuracy and precision to 3 digits.

10 views (last 30 days)
meh hadi on 25 Apr 2018
Commented: Walter Roberson on 2 May 2018
for example I want to a=2.18+0.139; with 3 digits answer must be 2.31. is any way to do this?
Tom Wenk on 25 Apr 2018
Then I think you have to use the symbolic toolbox like Walter Robinson stated.
But why do you want to change 2.319 to 2.31 rather than 2.32? If you use this value for further calculations you should round in my opinion..

Praveen Iyyappan Valsala on 25 Apr 2018
I don't know any inbulit function which can do that. But, you can try something like below
trun=@(num,Ndigits)floor(a*10^Ndigits)/10^Ndigits;
trun_a=trun(a,2);

Walter Roberson on 25 Apr 2018
No, there is no built-in way.
You can use the symbolic toolbox with digits set to 3, but that will round rather than truncate.
Stephen on 26 Apr 2018
Note that setting the digits does not mean that calculations will be performed with exactly that precision, because calculations may use guard digits.

Tom Wenk on 25 Apr 2018
Like Walter Roberson stated, I think you have to use the symbolic toolbox for that.
Walter Roberson on 2 May 2018
For addition: multiply the original values by 100, take floor() or fix(). Do the addition. Divide the result by 100.