using System; using System.Globalization; using System.Runtime.CompilerServices; using System.Runtime.ConstrainedExecution; using System.Runtime.InteropServices; namespace System { /// Represents a double-precision floating-point number. /// 1 // Token: 0x02000020 RID: 32 [ComVisible(true)] [Serializable] public struct Double : IFormattable, IConvertible, IComparable, IComparable, IEquatable { /// For a description of this member, see . /// The value of the current instance, converted to . /// The type to which to convert this value. /// An implementation that supplies culture-specific information about the format of the returned value. // Token: 0x060002A0 RID: 672 RVA: 0x0000B1D0 File Offset: 0x000093D0 object IConvertible.ToType(Type targetType, IFormatProvider provider) { if (targetType == null) { throw new ArgumentNullException("targetType"); } return Convert.ToType(this, targetType, provider, false); } /// For a description of this member, see . /// true if the value of the current instance is not zero; otherwise, false. /// This parameter is ignored. // Token: 0x060002A1 RID: 673 RVA: 0x0000B200 File Offset: 0x00009400 bool IConvertible.ToBoolean(IFormatProvider provider) { return Convert.ToBoolean(this); } /// For a description of this member, see . /// The value of the current instance, converted to a . /// This parameter is ignored. // Token: 0x060002A2 RID: 674 RVA: 0x0000B20C File Offset: 0x0000940C byte IConvertible.ToByte(IFormatProvider provider) { return Convert.ToByte(this); } /// This conversion is not supported. Attempting to use this method throws an . /// This conversion is not supported. No value is returned. /// This parameter is ignored. /// In all cases. // Token: 0x060002A3 RID: 675 RVA: 0x0000B218 File Offset: 0x00009418 char IConvertible.ToChar(IFormatProvider provider) { throw new InvalidCastException(); } /// This conversion is not supported. Attempting to use this method throws an /// This conversion is not supported. No value is returned. /// This parameter is ignored. /// In all cases. // Token: 0x060002A4 RID: 676 RVA: 0x0000B220 File Offset: 0x00009420 DateTime IConvertible.ToDateTime(IFormatProvider provider) { throw new InvalidCastException(); } /// For a description of this member, see . /// The value of the current instance, converted to a . /// This parameter is ignored. // Token: 0x060002A5 RID: 677 RVA: 0x0000B228 File Offset: 0x00009428 decimal IConvertible.ToDecimal(IFormatProvider provider) { return Convert.ToDecimal(this); } /// For a description of this member, see . /// The value of the current instance, unchanged. /// This parameter is ignored. // Token: 0x060002A6 RID: 678 RVA: 0x0000B234 File Offset: 0x00009434 double IConvertible.ToDouble(IFormatProvider provider) { return Convert.ToDouble(this); } /// For a description of this member, see . /// The value of the current instance, converted to an . /// This parameter is ignored. // Token: 0x060002A7 RID: 679 RVA: 0x0000B240 File Offset: 0x00009440 short IConvertible.ToInt16(IFormatProvider provider) { return Convert.ToInt16(this); } /// For a description of this member, see . /// The value of the current instance, converted to an . /// This parameter is ignored. // Token: 0x060002A8 RID: 680 RVA: 0x0000B24C File Offset: 0x0000944C int IConvertible.ToInt32(IFormatProvider provider) { return Convert.ToInt32(this); } /// For a description of this member, see . /// The value of the current instance, converted to an . /// This parameter is ignored. // Token: 0x060002A9 RID: 681 RVA: 0x0000B258 File Offset: 0x00009458 long IConvertible.ToInt64(IFormatProvider provider) { return Convert.ToInt64(this); } /// For a description of this member, see . /// The value of the current instance, converted to an . /// This parameter is ignored. // Token: 0x060002AA RID: 682 RVA: 0x0000B264 File Offset: 0x00009464 sbyte IConvertible.ToSByte(IFormatProvider provider) { return Convert.ToSByte(this); } /// For a description of this member, see . /// The value of the current instance, converted to a . /// This parameter is ignored. // Token: 0x060002AB RID: 683 RVA: 0x0000B270 File Offset: 0x00009470 float IConvertible.ToSingle(IFormatProvider provider) { return Convert.ToSingle(this); } /// For a description of this member, see . /// The value of the current instance, converted to a . /// This parameter is ignored. // Token: 0x060002AC RID: 684 RVA: 0x0000B27C File Offset: 0x0000947C ushort IConvertible.ToUInt16(IFormatProvider provider) { return Convert.ToUInt16(this); } /// For a description of this member, see . /// The value of the current instance, converted to a . /// This parameter is ignored. // Token: 0x060002AD RID: 685 RVA: 0x0000B288 File Offset: 0x00009488 uint IConvertible.ToUInt32(IFormatProvider provider) { return Convert.ToUInt32(this); } /// For a description of this member, see . /// The value of the current instance, converted to a . /// This parameter is ignored. // Token: 0x060002AE RID: 686 RVA: 0x0000B294 File Offset: 0x00009494 ulong IConvertible.ToUInt64(IFormatProvider provider) { return Convert.ToUInt64(this); } /// Compares this instance to a specified object and returns an integer that indicates whether the value of this instance is less than, equal to, or greater than the value of the specified object. /// A signed number indicating the relative values of this instance and .Value Description A negative integer This instance is less than .-or- This instance is not a number () and is a number. Zero This instance is equal to .-or- This instance and are both Double.NaN, , or A positive integer This instance is greater than .-or- This instance is a number and is not a number ().-or- is null. /// An object to compare, or null. /// /// is not a . /// 2 // Token: 0x060002AF RID: 687 RVA: 0x0000B2A0 File Offset: 0x000094A0 public int CompareTo(object value) { if (value == null) { return 1; } if (!(value is double)) { throw new ArgumentException(Locale.GetText("Value is not a System.Double")); } double num = (double)value; if (double.IsPositiveInfinity(this) && double.IsPositiveInfinity(num)) { return 0; } if (double.IsNegativeInfinity(this) && double.IsNegativeInfinity(num)) { return 0; } if (double.IsNaN(num)) { if (double.IsNaN(this)) { return 0; } return 1; } else if (double.IsNaN(this)) { if (double.IsNaN(num)) { return 0; } return -1; } else { if (this > num) { return 1; } if (this < num) { return -1; } return 0; } } /// Returns a value indicating whether this instance is equal to a specified object. /// true if is an instance of and equals the value of this instance; otherwise, false. /// An object to compare with this instance. /// 2 // Token: 0x060002B0 RID: 688 RVA: 0x0000B354 File Offset: 0x00009554 public override bool Equals(object obj) { if (!(obj is double)) { return false; } double num = (double)obj; if (double.IsNaN(num)) { return double.IsNaN(this); } return num == this; } /// Compares this instance to a specified double-precision floating-point number and returns an integer that indicates whether the value of this instance is less than, equal to, or greater than the value of the specified double-precision floating-point number. /// A signed number indicating the relative values of this instance and .Return Value Description Less than zero This instance is less than .-or- This instance is not a number () and is a number. Zero This instance is equal to .-or- Both this instance and are not a number (), , or . Greater than zero This instance is greater than .-or- This instance is a number and is not a number (). /// A double-precision floating-point number to compare. /// 2 // Token: 0x060002B1 RID: 689 RVA: 0x0000B390 File Offset: 0x00009590 public int CompareTo(double value) { if (double.IsPositiveInfinity(this) && double.IsPositiveInfinity(value)) { return 0; } if (double.IsNegativeInfinity(this) && double.IsNegativeInfinity(value)) { return 0; } if (double.IsNaN(value)) { if (double.IsNaN(this)) { return 0; } return 1; } else if (double.IsNaN(this)) { if (double.IsNaN(value)) { return 0; } return -1; } else { if (this > value) { return 1; } if (this < value) { return -1; } return 0; } } /// Returns a value indicating whether this instance and a specified object represent the same value. /// true if is equal to this instance; otherwise, false. /// A object to compare to this instance. /// 2 // Token: 0x060002B2 RID: 690 RVA: 0x0000B41C File Offset: 0x0000961C public bool Equals(double obj) { if (double.IsNaN(obj)) { return double.IsNaN(this); } return obj == this; } /// Returns the hash code for this instance. /// A 32-bit signed integer hash code. /// 2 // Token: 0x060002B3 RID: 691 RVA: 0x0000B44C File Offset: 0x0000964C public override int GetHashCode() { double num = this; return num.GetHashCode(); } /// Returns a value indicating whether the specified number evaluates to negative or positive infinity /// true if evaluates to or ; otherwise, false. /// A double-precision floating-point number. /// 1 // Token: 0x060002B4 RID: 692 RVA: 0x0000B464 File Offset: 0x00009664 public static bool IsInfinity(double d) { return d == double.PositiveInfinity || d == double.NegativeInfinity; } /// Returns a value indicating whether the specified number evaluates to a value that is not a number (). /// true if evaluates to ; otherwise, false. /// A double-precision floating-point number. /// 1 // Token: 0x060002B5 RID: 693 RVA: 0x0000B484 File Offset: 0x00009684 [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)] public static bool IsNaN(double d) { return d != d; } /// Returns a value indicating whether the specified number evaluates to negative infinity. /// true if evaluates to ; otherwise, false. /// A double-precision floating-point number. /// 1 // Token: 0x060002B6 RID: 694 RVA: 0x0000B490 File Offset: 0x00009690 public static bool IsNegativeInfinity(double d) { return d < 0.0 && (d == double.NegativeInfinity || d == double.PositiveInfinity); } /// Returns a value indicating whether the specified number evaluates to positive infinity. /// true if evaluates to ; otherwise, false. /// A double-precision floating-point number. /// 1 // Token: 0x060002B7 RID: 695 RVA: 0x0000B4D0 File Offset: 0x000096D0 public static bool IsPositiveInfinity(double d) { return d > 0.0 && (d == double.NegativeInfinity || d == double.PositiveInfinity); } /// Converts the string representation of a number to its double-precision floating-point number equivalent. /// A double-precision floating-point number equivalent to the numeric value or symbol specified in . Because of differences in precision, the return value may not be exactly equal to , and for values of that are less than , the return value may also differ depending on processor architecture. For more information, see the Remarks section of . /// A string containing a number to convert. /// /// is null. /// /// is not a number in a valid format. /// /// represents a number less than or greater than . /// 1 // Token: 0x060002B8 RID: 696 RVA: 0x0000B510 File Offset: 0x00009710 public static double Parse(string s) { return double.Parse(s, NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite | NumberStyles.AllowLeadingSign | NumberStyles.AllowDecimalPoint | NumberStyles.AllowThousands | NumberStyles.AllowExponent, null); } /// Converts the string representation of a number in a specified culture-specific format to its double-precision floating-point number equivalent. /// A double-precision floating-point number equivalent to the numeric value or symbol specified in . Because of differences in precision, the return value may not be exactly equal to , and for values of that are less than , the return value may also differ depending on processor architecture. For more information, see the Remarks section of . /// A string containing a number to convert. /// An that supplies culture-specific formatting information about . /// /// is null. /// /// is not a number in a valid format. /// /// represents a number less than or greater than . /// 1 // Token: 0x060002B9 RID: 697 RVA: 0x0000B520 File Offset: 0x00009720 public static double Parse(string s, IFormatProvider provider) { return double.Parse(s, NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite | NumberStyles.AllowLeadingSign | NumberStyles.AllowDecimalPoint | NumberStyles.AllowThousands | NumberStyles.AllowExponent, provider); } /// Converts the string representation of a number in a specified style to its double-precision floating-point number equivalent. /// A double-precision floating-point number equivalent to the numeric value or symbol specified in . Because of differences in precision, the return value may not be exactly equal to , and for values of that are less than , the return value may also differ depending on processor architecture. For more information, see the Remarks section of . /// A string containing a number to convert. /// A bitwise combination of values that indicates the style elements that can be present in . A typical value to specify is a combination of and . /// /// is null. /// /// is not a number in a valid format. /// /// represents a number less than or greater than . /// /// is not a value. -or- is the value. /// 1 // Token: 0x060002BA RID: 698 RVA: 0x0000B530 File Offset: 0x00009730 public static double Parse(string s, NumberStyles style) { return double.Parse(s, style, null); } /// Converts the string representation of a number in a specified style and culture-specific format to its double-precision floating-point number equivalent. /// A double-precision floating-point number equivalent to the numeric value or symbol specified in . Because of differences in precision, the return value may not be exactly equal to , and for values of that are less than , the return value may also differ depending on processor architecture. For more information, see the Remarks section of . /// A string containing a number to convert. /// A bitwise combination of values that indicates the style elements that can be present in . A typical value to specify is combined with . /// An object that supplies culture-specific formatting information about . /// /// is null. /// /// is not a numeric value. /// /// is not a value. -or- is the value. /// /// represents a number less than or greater than . /// 1 // Token: 0x060002BB RID: 699 RVA: 0x0000B53C File Offset: 0x0000973C public static double Parse(string s, NumberStyles style, IFormatProvider provider) { double num; Exception ex; if (!double.Parse(s, style, provider, false, out num, out ex)) { throw ex; } return num; } // Token: 0x060002BC RID: 700 RVA: 0x0000B560 File Offset: 0x00009760 internal unsafe static bool Parse(string s, NumberStyles style, IFormatProvider provider, bool tryParse, out double result, out Exception exc) { result = 0.0; exc = null; if (s == null) { if (!tryParse) { exc = new ArgumentNullException("s"); } return false; } if (s.Length == 0) { if (!tryParse) { exc = new FormatException(); } return false; } if ((style & NumberStyles.AllowHexSpecifier) != NumberStyles.None) { string text = Locale.GetText("Double doesn't support parsing with '{0}'.", new object[] { "AllowHexSpecifier" }); throw new ArgumentException(text); } if (style > NumberStyles.Any) { if (!tryParse) { exc = new ArgumentException(); } return false; } NumberFormatInfo instance = NumberFormatInfo.GetInstance(provider); if (instance == null) { throw new Exception("How did this happen?"); } int length = s.Length; int num = 0; int i = 0; bool flag = (style & NumberStyles.AllowLeadingWhite) != NumberStyles.None; bool flag2 = (style & NumberStyles.AllowTrailingWhite) != NumberStyles.None; if (flag) { while (i < length && char.IsWhiteSpace(s[i])) { i++; } if (i == length) { if (!tryParse) { exc = int.GetFormatException(); } return false; } } int num2 = s.Length - 1; if (flag2) { while (char.IsWhiteSpace(s[num2])) { num2--; } } if (double.TryParseStringConstant(instance.NaNSymbol, s, i, num2)) { result = double.NaN; return true; } if (double.TryParseStringConstant(instance.PositiveInfinitySymbol, s, i, num2)) { result = double.PositiveInfinity; return true; } if (double.TryParseStringConstant(instance.NegativeInfinitySymbol, s, i, num2)) { result = double.NegativeInfinity; return true; } byte[] array = new byte[length + 1]; int num3 = 1; string text2 = null; string text3 = null; string text4 = null; int num4 = 0; int num5 = 0; int num6 = 0; if ((style & NumberStyles.AllowDecimalPoint) != NumberStyles.None) { text2 = instance.NumberDecimalSeparator; num4 = text2.Length; } if ((style & NumberStyles.AllowThousands) != NumberStyles.None) { text3 = instance.NumberGroupSeparator; num5 = text3.Length; } if ((style & NumberStyles.AllowCurrencySymbol) != NumberStyles.None) { text4 = instance.CurrencySymbol; num6 = text4.Length; } string positiveSign = instance.PositiveSign; string negativeSign = instance.NegativeSign; while (i < length) { char c = s[i]; if (c == '\0') { i = length; } else { switch (num3) { case 1: if ((style & NumberStyles.AllowLeadingSign) != NumberStyles.None) { if (c == positiveSign[0] && s.Substring(i, positiveSign.Length) == positiveSign) { num3 = 2; i += positiveSign.Length - 1; goto IL_624; } if (c == negativeSign[0] && s.Substring(i, negativeSign.Length) == negativeSign) { num3 = 2; array[num++] = 45; i += negativeSign.Length - 1; goto IL_624; } } num3 = 2; goto IL_304; case 2: goto IL_304; case 3: goto IL_429; case 4: if (char.IsDigit(c)) { num3 = 5; goto IL_599; } if (c == positiveSign[0] && s.Substring(i, positiveSign.Length) == positiveSign) { num3 = 2; i += positiveSign.Length - 1; goto IL_624; } if (c == negativeSign[0] && s.Substring(i, negativeSign.Length) == negativeSign) { num3 = 2; array[num++] = 45; i += negativeSign.Length - 1; goto IL_624; } if (char.IsWhiteSpace(c)) { goto IL_5E7; } if (!tryParse) { exc = new FormatException("Unknown char: " + c); } return false; case 5: goto IL_599; case 6: goto IL_5E7; } IL_617: if (num3 == 7) { break; } goto IL_624; IL_429: if (char.IsDigit(c)) { array[num++] = (byte)c; goto IL_617; } if (c == 'e' || c == 'E') { if ((style & NumberStyles.AllowExponent) == NumberStyles.None) { if (!tryParse) { exc = new FormatException("Unknown char: " + c); } return false; } array[num++] = (byte)c; num3 = 4; goto IL_617; } else { if (char.IsWhiteSpace(c)) { goto IL_5E7; } if (!tryParse) { exc = new FormatException("Unknown char: " + c); } return false; } IL_304: if (char.IsDigit(c)) { array[num++] = (byte)c; goto IL_617; } if (c == 'e' || c == 'E') { goto IL_429; } if (num4 > 0 && text2[0] == c && string.CompareOrdinal(s, i, text2, 0, num4) == 0) { array[num++] = 46; i += num4 - 1; num3 = 3; goto IL_617; } if (num5 > 0 && text3[0] == c && s.Substring(i, num5) == text3) { i += num5 - 1; num3 = 2; goto IL_617; } if (num6 > 0 && text4[0] == c && s.Substring(i, num6) == text4) { i += num6 - 1; num3 = 2; goto IL_617; } if (char.IsWhiteSpace(c)) { goto IL_5E7; } if (!tryParse) { exc = new FormatException("Unknown char: " + c); } return false; IL_599: if (char.IsDigit(c)) { array[num++] = (byte)c; goto IL_617; } if (!char.IsWhiteSpace(c)) { if (!tryParse) { exc = new FormatException("Unknown char: " + c); } return false; } IL_5E7: if (flag2 && char.IsWhiteSpace(c)) { num3 = 6; goto IL_617; } if (!tryParse) { exc = new FormatException("Unknown char"); } return false; } IL_624: i++; } array[num] = 0; double num7; if (!double.ParseImpl(&array[0], out num7)) { if (!tryParse) { exc = int.GetFormatException(); } return false; } if (double.IsPositiveInfinity(num7) || double.IsNegativeInfinity(num7)) { if (!tryParse) { exc = new OverflowException(); } return false; } result = num7; return true; } // Token: 0x060002BD RID: 701 RVA: 0x0000BBFC File Offset: 0x00009DFC private static bool TryParseStringConstant(string format, string s, int start, int end) { return end - start + 1 == format.Length && string.CompareOrdinal(format, 0, s, start, format.Length) == 0; } // Token: 0x060002BE RID: 702 [MethodImpl(MethodImplOptions.InternalCall)] private unsafe static extern bool ParseImpl(byte* byte_ptr, out double value); /// Converts the string representation of a number in a specified style and culture-specific format to its double-precision floating-point number equivalent. A return value indicates whether the conversion succeeded or failed. /// true if was converted successfully; otherwise, false. /// A string containing a number to convert. /// A bitwise combination of values that indicates the permitted format of . A typical value to specify is combined with . /// An that supplies culture-specific formatting information about . /// When this method returns, contains a double-precision floating-point number equivalent to the numeric value or symbol contained in , if the conversion succeeded, or zero if the conversion failed. The conversion fails if the parameter is null, is not in a format compliant with , represents a number less than or greater than , or if is not a valid combination of enumerated constants. This parameter is passed uninitialized. /// /// is not a value. -or- includes the value. /// 1 // Token: 0x060002BF RID: 703 RVA: 0x0000BC30 File Offset: 0x00009E30 public static bool TryParse(string s, NumberStyles style, IFormatProvider provider, out double result) { Exception ex; if (!double.Parse(s, style, provider, true, out result, out ex)) { result = 0.0; return false; } return true; } /// Converts the string representation of a number to its double-precision floating-point number equivalent. A return value indicates whether the conversion succeeded or failed. /// true if was converted successfully; otherwise, false. /// A string containing a number to convert. /// When this method returns, contains the double-precision floating-point number equivalent to the parameter, if the conversion succeeded, or zero if the conversion failed. The conversion fails if the parameter is null, is not a number in a valid format, or represents a number less than or greater than . This parameter is passed uninitialized. /// 1 // Token: 0x060002C0 RID: 704 RVA: 0x0000BC5C File Offset: 0x00009E5C public static bool TryParse(string s, out double result) { return double.TryParse(s, NumberStyles.Any, null, out result); } /// Converts the numeric value of this instance to its equivalent string representation. /// The string representation of the value of this instance. /// 1 // Token: 0x060002C1 RID: 705 RVA: 0x0000BC6C File Offset: 0x00009E6C public override string ToString() { return NumberFormatter.NumberToString(this, null); } /// Converts the numeric value of this instance to its equivalent string representation using the specified culture-specific format information. /// The string representation of the value of this instance as specified by . /// An that supplies culture-specific formatting information. /// 1 // Token: 0x060002C2 RID: 706 RVA: 0x0000BC78 File Offset: 0x00009E78 public string ToString(IFormatProvider provider) { return NumberFormatter.NumberToString(this, provider); } /// Converts the numeric value of this instance to its equivalent string representation, using the specified format. /// The string representation of the value of this instance as specified by . /// A numeric format string (see Remarks). /// /// is invalid. /// 1 // Token: 0x060002C3 RID: 707 RVA: 0x0000BC84 File Offset: 0x00009E84 public string ToString(string format) { return this.ToString(format, null); } /// Converts the numeric value of this instance to its equivalent string representation using the specified format and culture-specific format information. /// The string representation of the value of this instance as specified by and . /// A numeric format string (see Remarks). /// An that supplies culture-specific formatting information. /// 1 // Token: 0x060002C4 RID: 708 RVA: 0x0000BC90 File Offset: 0x00009E90 public string ToString(string format, IFormatProvider provider) { return NumberFormatter.NumberToString(format, this, provider); } /// Returns the for value type . /// The enumerated constant, . /// 2 // Token: 0x060002C5 RID: 709 RVA: 0x0000BC9C File Offset: 0x00009E9C public TypeCode GetTypeCode() { return TypeCode.Double; } /// Represents the smallest positive value greater than zero. This field is constant. /// 1 // Token: 0x04000034 RID: 52 public const double Epsilon = 5E-324; /// Represents the largest possible value of a . This field is constant. /// 1 // Token: 0x04000035 RID: 53 public const double MaxValue = 1.7976931348623157E+308; /// Represents the smallest possible value of a . This field is constant. /// 1 // Token: 0x04000036 RID: 54 public const double MinValue = -1.7976931348623157E+308; /// Represents a value that is not a number (NaN). This field is constant. /// 1 // Token: 0x04000037 RID: 55 public const double NaN = double.NaN; /// Represents negative infinity. This field is constant. /// 1 // Token: 0x04000038 RID: 56 public const double NegativeInfinity = double.NegativeInfinity; /// Represents positive infinity. This field is constant. /// 1 // Token: 0x04000039 RID: 57 public const double PositiveInfinity = double.PositiveInfinity; // Token: 0x0400003A RID: 58 private const int State_AllowSign = 1; // Token: 0x0400003B RID: 59 private const int State_Digits = 2; // Token: 0x0400003C RID: 60 private const int State_Decimal = 3; // Token: 0x0400003D RID: 61 private const int State_ExponentSign = 4; // Token: 0x0400003E RID: 62 private const int State_Exponent = 5; // Token: 0x0400003F RID: 63 private const int State_ConsumeWhiteSpace = 6; // Token: 0x04000040 RID: 64 private const int State_Exit = 7; // Token: 0x04000041 RID: 65 internal double m_value; } }