Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
The greatest lower number
Message
From
19/05/2002 11:42:07
 
 
To
19/05/2002 10:54:47
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00658665
Message ID:
00658671
Views:
19
>Given a specific decimal places, I need to know the nearest number lower that a specified number.
>For example:
>
>Decimal places: 2
>Given number: 51245.54468
>Desired number: 51245.54
>
>Decimal places: 1
>Given number: the same as above
>Desired number: 51245.5
>
>Decimal places: 0
>Given number: the same as above
>Desired number: 51245
>
>What's the shortest code to achieve this?

Certainly not the fastest, but (I believe) one of the shortest:
INT(m.lnNumber*10^m.lnDecimalPlaces)/10^m.lnDecimalPlaces
Also, it won't give you the nearest lower number, but the nearest number closer to zero.
----------------------------------
António Tavares Lopes
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform