Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Quiz on Programming
Message
From
01/04/1998 16:10:42
 
 
To
01/04/1998 11:42:49
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00088587
Message ID:
00088791
Views:
33
>>>If you can't use Int(), Round(), Floor(), Ceiling() or
>>>any similar function to cut off integer.
>>>
>>>cAn you write a function equiv. to Round()?
>>>Of cos, You can use / and % (mod) ^_^;
>>
>>Off the top of my head
>>
>>lcdeci = SET ('Decimals')
>>x='3423432.3523'
>>SET DECIMAL TO 0 && if not, you get trailing 0's on ?y to screen
>>y=VAL(STR(x))
>>SET DECIMALS TO lcdeci && Set Deci back to default
>>
>>*****
>>This is how I would do it if I couldn't use the built in functions.
>
>
>#___#' Actually, I should say: Suppose You are the low level developer.
>
>You need to use coding of +, -, *, /, % to make the Round(), Int(),....
>to other on use and therefore, There should be no simply method to do...
>Actually, Str(nNumber, NLength [, nDecimal]) are calling Round() in its
>internal... So, not really answer it!
>
>Coding will like:
>if nNumber - 0.5 > ?? && then
> nNumber = nNumber + 1
>....
>endif

n=1467.89
? val(left(str(n,20,10),at(".",str(n,20,10))-1))
BTW, it's recommended to use available VFP functions:)
Edward Pikman
Independent Consultant
Previous
Reply
Map
View

Click here to load this message in the networking platform