Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
The simplest way to convert a number?
Message
De
31/10/2001 04:59:39
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00575272
Message ID:
00575509
Vues:
20
This message has been marked as a message which has helped to the initial question of the thread.
Nadya,

I found this function in a FoxBase or FoxPro book many years ago, and it’s still in my tool kit:
FUNCTION RoundX
**********************************************
* Function : RoundX(expN1, expN2)
*          : expN1 = Number to Round
*          : expN2 = Precision
*
* Ex.      : ?RoundX(123.27, 0.5) = 123.50
*          : ?RoundX(123.27, 100) = 100.00
**********************************************
LPARAMETERS;
 lnNumber,;
 lnTo

RETURN IIF(lnTo = 0, lnNumber, lnTo * INT((lnNumber + (lnTo / 2)) / lnTo))
>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?
>
>Thanks in advance.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform