|
Cet article a fait l'objet d'une traduction manuelle. Déplacez votre pointeur sur les phrases de l'article pour voir la version originale de ce texte.
|
Traduction
Source
|
Double, structure
Assembly : mscorlib (dans mscorlib.dll)
Le type Double expose les membres suivants.
| Nom | Description | |
|---|---|---|
![]() ![]() ![]() | CompareTo(Double) | |
![]() ![]() | CompareTo(Object) | |
![]() ![]() ![]() | Equals(Double) | |
![]() ![]() ![]() | Equals(Object) | |
![]() ![]() ![]() | Finalize | |
![]() ![]() ![]() | GetHashCode | |
![]() ![]() ![]() | GetType | |
![]() ![]() | GetTypeCode | |
![]() ![]() ![]() ![]() | IsInfinity | |
![]() ![]() ![]() ![]() | IsNaN | |
![]() ![]() ![]() ![]() | IsNegativeInfinity | |
![]() ![]() ![]() ![]() | IsPositiveInfinity | |
![]() ![]() ![]() | MemberwiseClone | |
![]() ![]() ![]() | Parse(String) | |
![]() ![]() ![]() | Parse(String, NumberStyles) | |
![]() ![]() ![]() ![]() | Parse(String, IFormatProvider) | |
![]() ![]() ![]() ![]() | Parse(String, NumberStyles, IFormatProvider) | |
![]() ![]() ![]() | ToString() | |
![]() ![]() ![]() | ToString(IFormatProvider) | |
![]() ![]() | ToString(String) | |
![]() ![]() ![]() | ToString(String, IFormatProvider) | |
![]() ![]() | TryParse(String, Double) | |
![]() ![]() ![]() | TryParse(String, NumberStyles, IFormatProvider, Double) |
| Nom | Description | |
|---|---|---|
![]() ![]() | Equality | |
![]() ![]() | GreaterThan | |
![]() ![]() | GreaterThanOrEqual | |
![]() ![]() | Inequality | |
![]() ![]() | LessThan | |
![]() ![]() | LessThanOrEqual |
| Nom | Description | |
|---|---|---|
![]() ![]() ![]() ![]() | Epsilon | |
![]() ![]() ![]() ![]() | MaxValue | |
![]() ![]() ![]() ![]() | MinValue | |
![]() ![]() ![]() ![]() | NaN | |
![]() ![]() ![]() ![]() | NegativeInfinity | |
![]() ![]() ![]() ![]() | PositiveInfinity |
| Nom | Description | |
|---|---|---|
![]() ![]() ![]() | IConvertible.ToBoolean | Infrastructure. |
![]() ![]() ![]() | IConvertible.ToByte | Infrastructure. |
![]() ![]() ![]() | IConvertible.ToChar | Infrastructure. |
![]() ![]() ![]() | IConvertible.ToDateTime | Infrastructure. |
![]() ![]() ![]() | IConvertible.ToDecimal | Infrastructure. |
![]() ![]() ![]() | IConvertible.ToDouble | Infrastructure. |
![]() ![]() ![]() | IConvertible.ToInt16 | Infrastructure. |
![]() ![]() ![]() | IConvertible.ToInt32 | Infrastructure. |
![]() ![]() ![]() | IConvertible.ToInt64 | Infrastructure. |
![]() ![]() ![]() | IConvertible.ToSByte | Infrastructure. |
![]() ![]() ![]() | IConvertible.ToSingle | Infrastructure. |
![]() ![]() ![]() | IConvertible.ToType | Infrastructure. |
![]() ![]() ![]() | IConvertible.ToUInt16 | Infrastructure. |
![]() ![]() ![]() | IConvertible.ToUInt32 | Infrastructure. |
![]() ![]() ![]() | IConvertible.ToUInt64 | Infrastructure. |
Utilisation de nombres à virgule flottante
Si le résultat d'une opération en virgule flottante est trop petit pour le format de destination, le résultat de l'opération est alors zéro. Si le résultat d'une opération en virgule flottante est trop grand pour le format de destination, le résultat de l'opération est alors PositiveInfinity ou NegativeInfinity, en fonction du signe du résultat. Si une opération en virgule flottante n'est pas valide, le résultat de l'opération est alors NaN. Si un ou deux opérandes d'une opération en virgule flottante sont NaN, le résultat de l'opération est alors NaN.
Valeurs à virgule flottante et perte de précision
Deux nombres à virgule flottante qui apparaissent égaux à un niveau de précision particulier peuvent ne pas être égaux parce que leurs chiffres les moins significatifs sont différents. Une opération mathématique ou de comparaison qui utilise un nombre à virgule flottante peut pas avoir le même résultat si un nombre décimal est utilisé, car le nombre à virgule flottante peut ne pas se rapprocher exactement du nombre décimal. Une valeur peut ne pas effectuer un aller-retour si un nombre à virgule flottante est impliqué. Une valeur est décrite comme effectuant un aller-retour si une opération convertit un nombre à virgule flottante d'origine dans une autre forme, si une opération inverse transforme la forme convertie en nombre à virgule flottante, et si le dernier nombre à virgule flottante est égal au nombre à virgule flottante d'origine. L'aller-retour peut échouer parce qu'un ou plusieurs chiffres moins significatifs sont perdus ou modifiés au cours d'une conversion.
double value = -4.42330604244772E-305; double fromLiteral = -4.42330604244772E-305; double fromVariable = value; double fromParse = Double.Parse("-4.42330604244772E-305"); Console.WriteLine("Double value from literal: {0,29:R}", fromLiteral); Console.WriteLine("Double value from variable: {0,28:R}", fromVariable); Console.WriteLine("Double value from Parse method: {0,24:R}", fromParse); // On 32-bit versions of the .NET Framework, the output is: // Double value from literal: -4.42330604244772E-305 // Double value from variable: -4.42330604244772E-305 // Double value from Parse method: -4.42330604244772E-305 // // On other versions of the .NET Framework, the output is: // Double value from literal: -4.4233060424477198E-305 // Double value from variable: -4.4233060424477198E-305 // Double value from Parse method: -4.42330604244772E-305
/// <summary> /// Temperature class stores the value as Double /// and delegates most of the functionality /// to the Double implementation. /// </summary> public class Temperature : IComparable, IFormattable { /// <summary> /// IComparable.CompareTo implementation. /// </summary> public int CompareTo(object obj) { if(obj is Temperature) { Temperature temp = (Temperature) obj; return m_value.CompareTo(temp.m_value); } throw new ArgumentException("object is not a Temperature"); } /// <summary> /// IFormattable.ToString implementation. /// </summary> public string ToString(string format, IFormatProvider provider) { if( format != null ) { if( format.Equals("F") ) { return String.Format("{0}'F", this.Value.ToString()); } if( format.Equals("C") ) { return String.Format("{0}'C", this.Celsius.ToString()); } } return m_value.ToString(format, provider); } /// <summary> /// Parses the temperature from a string in form /// [ws][sign]digits['F|'C][ws] /// </summary> public static Temperature Parse(string s, NumberStyles styles, IFormatProvider provider) { Temperature temp = new Temperature(); if( s.TrimEnd(null).EndsWith("'F") ) { temp.Value = Double.Parse( s.Remove(s.LastIndexOf('\''), 2), styles, provider); } else if( s.TrimEnd(null).EndsWith("'C") ) { temp.Celsius = Double.Parse( s.Remove(s.LastIndexOf('\''), 2), styles, provider); } else { temp.Value = Double.Parse(s, styles, provider); } return temp; } // The value holder protected double m_value; public double Value { get { return m_value; } set { m_value = value; } } public double Celsius { get { return (m_value-32.0)/1.8; } set { m_value = 1.8*value+32.0; } } }
Windows 7, Windows Vista SP1 ou ultérieur, Windows XP SP3, Windows XP SP2 Édition x64, Windows Server 2008 (installation minimale non prise en charge), Windows Server 2008 R2 (installation minimale prise en charge avec SP1 ou version ultérieure), Windows Server 2003 SP2
Le .NET Framework ne prend pas en charge toutes les versions de chaque plateforme. Pour obtenir la liste des versions prises en charge, consultez Configuration requise du .NET Framework.
Attention |
|---|

