Arrondir un decimal

Résolu
emna_bz Messages postés 25 Date d'inscription jeudi 3 mars 2005 Statut Membre Dernière intervention 25 janvier 2006 - 1 juin 2005 à 16:45
cantonaifou Messages postés 9 Date d'inscription mercredi 19 mai 2004 Statut Membre Dernière intervention 1 juin 2005 - 1 juin 2005 à 17:57
Bonjour,
Je travail avec c# et je veux me limiter d'avoir des chiffres de type decimal avec 3 chiffres apres la virgule,comment je peux faire cela?
par exemple 1.0246328 je veux la reduire a 1.024.
Merci bien de m'aider.

1 réponse

cantonaifou Messages postés 9 Date d'inscription mercredi 19 mai 2004 Statut Membre Dernière intervention 1 juin 2005
1 juin 2005 à 17:57
[C#]
public static [ms-help://MS.VSCC.2003/MS.MSDNQTR.2003FEB.1036/cpref/html/frlrfsystemdecimalclasstopic.htm decimal] Round(
[ms-help://MS.VSCC.2003/MS.MSDNQTR.2003FEB.1036/cpref/html/frlrfsystemdecimalclasstopic.htm decimal] [ d],
[ms-help://MS.VSCC.2003/MS.MSDNQTR.2003FEB.1036/cpref/html/frlrfsystemint32classtopic.htm int] [ decimals]
);



[C++]
public: static [ms-help://MS.VSCC.2003/MS.MSDNQTR.2003FEB.1036/cpref/html/frlrfsystemdecimalclasstopic.htm Decimal] Round(
[ms-help://MS.VSCC.2003/MS.MSDNQTR.2003FEB.1036/cpref/html/frlrfsystemdecimalclasstopic.htm Decimal] [ d],
[ms-help://MS.VSCC.2003/MS.MSDNQTR.2003FEB.1036/cpref/html/frlrfsystemint32classtopic.htm int] [ decimals]
);



[JScript]
public static function Round(
[ d] : [ms-help://MS.VSCC.2003/MS.MSDNQTR.2003FEB.1036/cpref/html/frlrfsystemdecimalclasstopic.htm Decimal],
[ decimals] : [ms-help://MS.VSCC.2003/MS.MSDNQTR.2003FEB.1036/cpref/html/frlrfsystemint32classtopic.htm int]
) : [ms-help://MS.VSCC.2003/MS.MSDNQTR.2003FEB.1036/cpref/html/frlrfsystemdecimalclasstopic.htm Decimal];




Paramètres


* d : Valeur Decimal à arrondir.
* decimals : Valeur de 0 à 28 qui spécifie le nombre de décimales auquel arrondir le
chiffre.



decimal.Round(1.223654, 2) ==> 1.22



MSDN

cantonaifou c'est pour la vie
3
Rejoignez-nous