Rounding a decimal down
4 views (last 30 days)
Show older comments
L'O.G. on 2 Dec 2022
Commented: Vilém Frynta on 3 Dec 2022
With round(x,2) I can round a number to the nearest hundredth, but how do I round down to the nearest hundredth? For example, both 0.143 and 0.147 should become 0.14.
Matt J on 2 Dec 2022
Edited: Matt J on 2 Dec 2022
More Answers (2)
Vilém Frynta on 2 Dec 2022
Edited: Vilém Frynta on 2 Dec 2022
X = 0.143;
Y = sprintf('%.2f',X);
Y = str2double(Y)
Someone ahd same question before. Next time, try to Google your question before asking.
Find more on Agriculture in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!