how to count a number of digits.

10 visualizaciones (últimos 30 días)
komal Bhandari
komal Bhandari el 3 de Nov. de 2011
Respondida: Melisa Sahin el 23 de Jun. de 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.

Respuesta aceptada

Walter Roberson
Walter Roberson el 3 de Nov. de 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 comentarios
komal Bhandari
komal Bhandari el 3 de Nov. de 2011
i know but i mean to say if there any word to describe the no value situation..
komal Bhandari
komal Bhandari el 3 de Nov. de 2011
I got it sir. do not worry.

Iniciar sesión para comentar.

Más respuestas (2)

Jake Bolanski
Jake Bolanski el 3 de Nov. de 2011
I'd go with what Walter mentioned. However, in general length is the ideal way to go.
  1 comentario
Walter Roberson
Walter Roberson el 3 de Nov. de 2011
length() of the formatted string is considerably slower than log10.

Iniciar sesión para comentar.


Melisa Sahin
Melisa Sahin el 23 de Jun. de 2020
How counts of number digits use a recursion function ?

Categorías

Más información sobre Loops and Conditional Statements en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by