Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Check for number of digits in a number
Message
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00598086
Message ID:
00598105
Vues:
24
Hi!

Nadya, if your number is represented already as a string, the number of digits is:

len(m.lcString) - len(chrtran(m.lcString,'0123456789',''))

If it is a number, you have to convert it to the string. This can cause losing zeros that are at start or end of the number (for example, transform(12.3456000) = '12.3456'). In addition, new zeros could be added with different situation. If this is a data field, it is better to calculate the number of digits in the integer part of the number, then add to them number of digits after point (scale).

Note that in some cases '+' and '-' signs are also accounted as digits.

HTH.

>Hi everyone,
>
>I've checked old messages, but didn't find a solution for this problem: I need to find out the number of digits in a number. Say, I have 12.3456000 - the number of digits should be seven. I don't see a simple solution, so may be you can advise?
>
>Thanks a lot in advance.
Vlad Grynchyshyn, Project Manager, MCP
vgryn@yahoo.com
ICQ #10709245
The professional level of programmer could be determined by level of stupidity of his/her bugs

It is not appropriate to say that question is "foolish". There could be only foolish answers. Everybody passed period of time when knows nothing about something.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform