how to count a number of digits.
10 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
komal Bhandari
il 3 Nov 2011
Risposto: Melisa Sahin
il 23 Giu 2020
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 Commenti
Risposta accettata
Walter Roberson
il 3 Nov 2011
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
4 Commenti
Più risposte (2)
Jake Bolanski
il 3 Nov 2011
I'd go with what Walter mentioned. However, in general length is the ideal way to go.
1 Commento
Vedere anche
Categorie
Scopri di più su Loops and Conditional Statements in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!