how to count a number of digits.
20 次查看(过去 30 天)
显示 更早的评论
How to count a number of digits in a given number withoud using numel and length(num2string()). probably use for loop or while loop.
0 个评论
采纳的回答
Walter Roberson
2011-11-3
Well, there is log10(). Or there is counting digits upward until your number is smaller than 10^digits. There are other counting methods too.
One question you are going to have to deal with is what to do if the number is negative. Another question to deal with is what to do if the number is between -1 and +1, such as 0.00043
更多回答(2 个)
Jake Bolanski
2011-11-3
I'd go with what Walter mentioned. However, in general length is the ideal way to go.
1 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!