Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Round() function
Message
De
08/05/2003 09:41:03
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivie
 
 
À
07/05/2003 23:19:54
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00785199
Message ID:
00786205
Vues:
18
>it's work...!!
>thanks for your help..
>by the way, i hope that someday there will be a function for this..

I doubt it, since your requierements are very specific (most people don't want this kind of rounding).

You can easily create your own function (UDF). I am including the function - which is fairly simple - and a test program. Put the function wherever it is easily accesible (see: SET PROCEDURE).

So, from now on, instead of using round(Number, 2), which doesn't give the results you desire, you can use RoundUp(Number ,2).

In general, you can create your own custom functions (and classes, too) for specific behaviour you need over and over again.


However, in this particular case, please note that the behaviour of the round() function is what many people expect - you should use RoundUp() only in very specific cases.
clear
? RoundUp(4.1, 0)
? RoundUp(4.01, 1)
? RoundUp(4.99, 1)
? RoundUp(5, 1)
? RoundUp(pi(), 2)
? RoundUp(15123, -3) && Nearest thousand

function RoundUp(tnNumber, tnDecimals)
return ceiling(tnNumber * 10^tnDecimals) / 10^tnDecimals
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform