Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
The simplest way to convert a number?
Message
From
31/10/2001 04:59:39
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00575272
Message ID:
00575509
Views:
21
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.
Previous
Reply
Map
View

Click here to load this message in the networking platform