Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
The simplest way to convert a number?
Message
De
30/10/2001 17:54:11
Dragan Nedeljkovich (En ligne)
Now officially retired
Zrenjanin, Serbia
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00575272
Message ID:
00575368
Vues:
20
This message has been marked as a message which has helped to the initial question of the thread.
>Hi everyone,
>
>I'd like to convert numbers to the following:
>
>5->5
>52->50
>333->300
>4567->5000
>1234567->1000000, e.g. to the round number.
>
>What would be the simplest algorithm for this?

?ROUND(x, -INT(LOG10(x)))

For negative numbers, slightly more complicated:

?ROUND(x, -INT(LOG10(ABS(x))))

Works for numbers not between -1 and 1... for them, then, it would need a +1 decimal more.

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform