Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Function that counts how many numbers are in numeric fie
Message
From
03/01/2002 09:37:18
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivia
 
 
To
03/01/2002 08:53:31
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00600219
Message ID:
00600247
Views:
18
>I was wondering if there is a function that will count the legth in a numeric field.
>
>My initial approach was to convert the numeric field to a character field, trim the field, and then use LEN().
>
>I am looking for the shortest route.
>
>Thanks..
>
>>> Wes

For the case of positive integers, you can use a combination of log10() and ceiling():

? ceiling(log10(12345))

You can also convert negative integers to positive with abs().

And, log10(0) would give you an error message.

Come to think of it, len(trans(MyNumber)) seems much simpler, after all.

Hilmar.
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
Previous
Reply
Map
View

Click here to load this message in the networking platform