Double 구조체

정의

배정밀도 부동 소수점 숫자를 나타냅니다.

public value class double : IComparable, IComparable<double>, IConvertible, IEquatable<double>, IFormattable
public value class double : IComparable<double>, IConvertible, IEquatable<double>, IParsable<double>, ISpanParsable<double>, IUtf8SpanParsable<double>, System::Numerics::IAdditionOperators<double, double, double>, System::Numerics::IAdditiveIdentity<double, double>, System::Numerics::IBinaryFloatingPointIeee754<double>, System::Numerics::IBinaryNumber<double>, System::Numerics::IBitwiseOperators<double, double, double>, System::Numerics::IComparisonOperators<double, double, bool>, System::Numerics::IDecrementOperators<double>, System::Numerics::IDivisionOperators<double, double, double>, System::Numerics::IEqualityOperators<double, double, bool>, System::Numerics::IExponentialFunctions<double>, System::Numerics::IFloatingPoint<double>, System::Numerics::IFloatingPointConstants<double>, System::Numerics::IFloatingPointIeee754<double>, System::Numerics::IHyperbolicFunctions<double>, System::Numerics::IIncrementOperators<double>, System::Numerics::ILogarithmicFunctions<double>, System::Numerics::IMinMaxValue<double>, System::Numerics::IModulusOperators<double, double, double>, System::Numerics::IMultiplicativeIdentity<double, double>, System::Numerics::IMultiplyOperators<double, double, double>, System::Numerics::INumber<double>, System::Numerics::INumberBase<double>, System::Numerics::IPowerFunctions<double>, System::Numerics::IRootFunctions<double>, System::Numerics::ISignedNumber<double>, System::Numerics::ISubtractionOperators<double, double, double>, System::Numerics::ITrigonometricFunctions<double>, System::Numerics::IUnaryNegationOperators<double, double>, System::Numerics::IUnaryPlusOperators<double, double>
public value class double : IComparable, IComparable<double>, IConvertible, IEquatable<double>, ISpanFormattable
public value class double : IComparable<double>, IConvertible, IEquatable<double>, IParsable<double>, ISpanParsable<double>, System::Numerics::IAdditionOperators<double, double, double>, System::Numerics::IAdditiveIdentity<double, double>, System::Numerics::IBinaryFloatingPointIeee754<double>, System::Numerics::IBinaryNumber<double>, System::Numerics::IBitwiseOperators<double, double, double>, System::Numerics::IComparisonOperators<double, double, bool>, System::Numerics::IDecrementOperators<double>, System::Numerics::IDivisionOperators<double, double, double>, System::Numerics::IEqualityOperators<double, double, bool>, System::Numerics::IExponentialFunctions<double>, System::Numerics::IFloatingPoint<double>, System::Numerics::IFloatingPointConstants<double>, System::Numerics::IFloatingPointIeee754<double>, System::Numerics::IHyperbolicFunctions<double>, System::Numerics::IIncrementOperators<double>, System::Numerics::ILogarithmicFunctions<double>, System::Numerics::IMinMaxValue<double>, System::Numerics::IModulusOperators<double, double, double>, System::Numerics::IMultiplicativeIdentity<double, double>, System::Numerics::IMultiplyOperators<double, double, double>, System::Numerics::INumber<double>, System::Numerics::INumberBase<double>, System::Numerics::IPowerFunctions<double>, System::Numerics::IRootFunctions<double>, System::Numerics::ISignedNumber<double>, System::Numerics::ISubtractionOperators<double, double, double>, System::Numerics::ITrigonometricFunctions<double>, System::Numerics::IUnaryNegationOperators<double, double>, System::Numerics::IUnaryPlusOperators<double, double>
public value class double : IComparable, IConvertible, IFormattable
public value class double : IComparable, IComparable<double>, IEquatable<double>, IFormattable
public struct Double : IComparable, IComparable<double>, IConvertible, IEquatable<double>, IFormattable
public readonly struct Double : IComparable<double>, IConvertible, IEquatable<double>, IParsable<double>, ISpanParsable<double>, IUtf8SpanParsable<double>, System.Numerics.IAdditionOperators<double,double,double>, System.Numerics.IAdditiveIdentity<double,double>, System.Numerics.IBinaryFloatingPointIeee754<double>, System.Numerics.IBinaryNumber<double>, System.Numerics.IBitwiseOperators<double,double,double>, System.Numerics.IComparisonOperators<double,double,bool>, System.Numerics.IDecrementOperators<double>, System.Numerics.IDivisionOperators<double,double,double>, System.Numerics.IEqualityOperators<double,double,bool>, System.Numerics.IExponentialFunctions<double>, System.Numerics.IFloatingPoint<double>, System.Numerics.IFloatingPointConstants<double>, System.Numerics.IFloatingPointIeee754<double>, System.Numerics.IHyperbolicFunctions<double>, System.Numerics.IIncrementOperators<double>, System.Numerics.ILogarithmicFunctions<double>, System.Numerics.IMinMaxValue<double>, System.Numerics.IModulusOperators<double,double,double>, System.Numerics.IMultiplicativeIdentity<double,double>, System.Numerics.IMultiplyOperators<double,double,double>, System.Numerics.INumber<double>, System.Numerics.INumberBase<double>, System.Numerics.IPowerFunctions<double>, System.Numerics.IRootFunctions<double>, System.Numerics.ISignedNumber<double>, System.Numerics.ISubtractionOperators<double,double,double>, System.Numerics.ITrigonometricFunctions<double>, System.Numerics.IUnaryNegationOperators<double,double>, System.Numerics.IUnaryPlusOperators<double,double>
public readonly struct Double : IComparable, IComparable<double>, IConvertible, IEquatable<double>, IFormattable
public readonly struct Double : IComparable, IComparable<double>, IConvertible, IEquatable<double>, ISpanFormattable
public readonly struct Double : IComparable<double>, IConvertible, IEquatable<double>, IParsable<double>, ISpanParsable<double>, System.Numerics.IAdditionOperators<double,double,double>, System.Numerics.IAdditiveIdentity<double,double>, System.Numerics.IBinaryFloatingPointIeee754<double>, System.Numerics.IBinaryNumber<double>, System.Numerics.IBitwiseOperators<double,double,double>, System.Numerics.IComparisonOperators<double,double,bool>, System.Numerics.IDecrementOperators<double>, System.Numerics.IDivisionOperators<double,double,double>, System.Numerics.IEqualityOperators<double,double,bool>, System.Numerics.IExponentialFunctions<double>, System.Numerics.IFloatingPoint<double>, System.Numerics.IFloatingPointConstants<double>, System.Numerics.IFloatingPointIeee754<double>, System.Numerics.IHyperbolicFunctions<double>, System.Numerics.IIncrementOperators<double>, System.Numerics.ILogarithmicFunctions<double>, System.Numerics.IMinMaxValue<double>, System.Numerics.IModulusOperators<double,double,double>, System.Numerics.IMultiplicativeIdentity<double,double>, System.Numerics.IMultiplyOperators<double,double,double>, System.Numerics.INumber<double>, System.Numerics.INumberBase<double>, System.Numerics.IPowerFunctions<double>, System.Numerics.IRootFunctions<double>, System.Numerics.ISignedNumber<double>, System.Numerics.ISubtractionOperators<double,double,double>, System.Numerics.ITrigonometricFunctions<double>, System.Numerics.IUnaryNegationOperators<double,double>, System.Numerics.IUnaryPlusOperators<double,double>
[System.Serializable]
public struct Double : IComparable, IConvertible, IFormattable
[System.Serializable]
[System.Runtime.InteropServices.ComVisible(true)]
public struct Double : IComparable, IComparable<double>, IConvertible, IEquatable<double>, IFormattable
public struct Double : IComparable, IComparable<double>, IEquatable<double>, IFormattable
type double = struct
    interface IConvertible
    interface IFormattable
type double = struct
    interface IConvertible
    interface IFormattable
    interface IParsable<double>
    interface ISpanFormattable
    interface ISpanParsable<double>
    interface IUtf8SpanFormattable
    interface IUtf8SpanParsable<double>
    interface IAdditionOperators<double, double, double>
    interface IAdditiveIdentity<double, double>
    interface IBinaryFloatingPointIeee754<double>
    interface IBinaryNumber<double>
    interface IBitwiseOperators<double, double, double>
    interface IComparisonOperators<double, double, bool>
    interface IEqualityOperators<double, double, bool>
    interface IDecrementOperators<double>
    interface IDivisionOperators<double, double, double>
    interface IIncrementOperators<double>
    interface IModulusOperators<double, double, double>
    interface IMultiplicativeIdentity<double, double>
    interface IMultiplyOperators<double, double, double>
    interface INumber<double>
    interface INumberBase<double>
    interface ISubtractionOperators<double, double, double>
    interface IUnaryNegationOperators<double, double>
    interface IUnaryPlusOperators<double, double>
    interface IExponentialFunctions<double>
    interface IFloatingPointConstants<double>
    interface IFloatingPoint<double>
    interface ISignedNumber<double>
    interface IFloatingPointIeee754<double>
    interface IHyperbolicFunctions<double>
    interface ILogarithmicFunctions<double>
    interface IPowerFunctions<double>
    interface IRootFunctions<double>
    interface ITrigonometricFunctions<double>
    interface IMinMaxValue<double>
type double = struct
    interface IConvertible
    interface ISpanFormattable
    interface IFormattable
type double = struct
    interface IConvertible
    interface IFormattable
    interface IParsable<double>
    interface ISpanFormattable
    interface ISpanParsable<double>
    interface IAdditionOperators<double, double, double>
    interface IAdditiveIdentity<double, double>
    interface IBinaryFloatingPointIeee754<double>
    interface IBinaryNumber<double>
    interface IBitwiseOperators<double, double, double>
    interface IComparisonOperators<double, double, bool>
    interface IEqualityOperators<double, double, bool>
    interface IDecrementOperators<double>
    interface IDivisionOperators<double, double, double>
    interface IIncrementOperators<double>
    interface IModulusOperators<double, double, double>
    interface IMultiplicativeIdentity<double, double>
    interface IMultiplyOperators<double, double, double>
    interface INumber<double>
    interface INumberBase<double>
    interface ISubtractionOperators<double, double, double>
    interface IUnaryNegationOperators<double, double>
    interface IUnaryPlusOperators<double, double>
    interface IExponentialFunctions<double>
    interface IFloatingPointConstants<double>
    interface IFloatingPoint<double>
    interface ISignedNumber<double>
    interface IFloatingPointIeee754<double>
    interface IHyperbolicFunctions<double>
    interface ILogarithmicFunctions<double>
    interface IPowerFunctions<double>
    interface IRootFunctions<double>
    interface ITrigonometricFunctions<double>
    interface IMinMaxValue<double>
type double = struct
    interface IConvertible
    interface IFormattable
    interface IParsable<double>
    interface ISpanFormattable
    interface ISpanParsable<double>
    interface IAdditionOperators<double, double, double>
    interface IAdditiveIdentity<double, double>
    interface IBinaryFloatingPointIeee754<double>
    interface IBinaryNumber<double>
    interface IBitwiseOperators<double, double, double>
    interface IComparisonOperators<double, double, bool>
    interface IEqualityOperators<double, double, bool>
    interface IDecrementOperators<double>
    interface IDivisionOperators<double, double, double>
    interface IIncrementOperators<double>
    interface IModulusOperators<double, double, double>
    interface IMultiplicativeIdentity<double, double>
    interface IMultiplyOperators<double, double, double>
    interface INumber<double>
    interface INumberBase<double>
    interface ISubtractionOperators<double, double, double>
    interface IUnaryNegationOperators<double, double>
    interface IUnaryPlusOperators<double, double>
    interface IUtf8SpanFormattable
    interface IUtf8SpanParsable<double>
    interface IExponentialFunctions<double>
    interface IFloatingPointConstants<double>
    interface IFloatingPoint<double>
    interface ISignedNumber<double>
    interface IFloatingPointIeee754<double>
    interface IHyperbolicFunctions<double>
    interface ILogarithmicFunctions<double>
    interface IPowerFunctions<double>
    interface IRootFunctions<double>
    interface ITrigonometricFunctions<double>
    interface IMinMaxValue<double>
[<System.Serializable>]
type double = struct
    interface IFormattable
    interface IConvertible
[<System.Serializable>]
[<System.Runtime.InteropServices.ComVisible(true)>]
type double = struct
    interface IFormattable
    interface IConvertible
type double = struct
    interface IFormattable
Public Structure Double
Implements IComparable, IComparable(Of Double), IConvertible, IEquatable(Of Double), IFormattable
Public Structure Double
Implements IAdditionOperators(Of Double, Double, Double), IAdditiveIdentity(Of Double, Double), IBinaryFloatingPointIeee754(Of Double), IBinaryNumber(Of Double), IBitwiseOperators(Of Double, Double, Double), IComparable(Of Double), IComparisonOperators(Of Double, Double, Boolean), IConvertible, IDecrementOperators(Of Double), IDivisionOperators(Of Double, Double, Double), IEqualityOperators(Of Double, Double, Boolean), IEquatable(Of Double), IExponentialFunctions(Of Double), IFloatingPoint(Of Double), IFloatingPointConstants(Of Double), IFloatingPointIeee754(Of Double), IHyperbolicFunctions(Of Double), IIncrementOperators(Of Double), ILogarithmicFunctions(Of Double), IMinMaxValue(Of Double), IModulusOperators(Of Double, Double, Double), IMultiplicativeIdentity(Of Double, Double), IMultiplyOperators(Of Double, Double, Double), INumber(Of Double), INumberBase(Of Double), IParsable(Of Double), IPowerFunctions(Of Double), IRootFunctions(Of Double), ISignedNumber(Of Double), ISpanParsable(Of Double), ISubtractionOperators(Of Double, Double, Double), ITrigonometricFunctions(Of Double), IUnaryNegationOperators(Of Double, Double), IUnaryPlusOperators(Of Double, Double), IUtf8SpanParsable(Of Double)
Public Structure Double
Implements IComparable, IComparable(Of Double), IConvertible, IEquatable(Of Double), ISpanFormattable
Public Structure Double
Implements IAdditionOperators(Of Double, Double, Double), IAdditiveIdentity(Of Double, Double), IBinaryFloatingPointIeee754(Of Double), IBinaryNumber(Of Double), IBitwiseOperators(Of Double, Double, Double), IComparable(Of Double), IComparisonOperators(Of Double, Double, Boolean), IConvertible, IDecrementOperators(Of Double), IDivisionOperators(Of Double, Double, Double), IEqualityOperators(Of Double, Double, Boolean), IEquatable(Of Double), IExponentialFunctions(Of Double), IFloatingPoint(Of Double), IFloatingPointConstants(Of Double), IFloatingPointIeee754(Of Double), IHyperbolicFunctions(Of Double), IIncrementOperators(Of Double), ILogarithmicFunctions(Of Double), IMinMaxValue(Of Double), IModulusOperators(Of Double, Double, Double), IMultiplicativeIdentity(Of Double, Double), IMultiplyOperators(Of Double, Double, Double), INumber(Of Double), INumberBase(Of Double), IParsable(Of Double), IPowerFunctions(Of Double), IRootFunctions(Of Double), ISignedNumber(Of Double), ISpanParsable(Of Double), ISubtractionOperators(Of Double, Double, Double), ITrigonometricFunctions(Of Double), IUnaryNegationOperators(Of Double, Double), IUnaryPlusOperators(Of Double, Double)
Public Structure Double
Implements IComparable, IConvertible, IFormattable
Public Structure Double
Implements IComparable, IComparable(Of Double), IEquatable(Of Double), IFormattable
상속
Double
특성
구현
IComparable IComparable<Double> IConvertible IEquatable<Double> IFormattable IComparable<TSelf> IEquatable<TSelf> IParsable<Double> IParsable<TSelf> ISpanFormattable ISpanParsable<Double> ISpanParsable<TSelf> IUtf8SpanFormattable IUtf8SpanParsable<Double> IUtf8SpanParsable<TSelf> IAdditionOperators<Double,Double,Double> IAdditionOperators<TSelf,TSelf,TSelf> IAdditiveIdentity<Double,Double> IAdditiveIdentity<TSelf,TSelf> IBinaryFloatingPointIeee754<Double> IBinaryNumber<Double> IBinaryNumber<TSelf> IBitwiseOperators<Double,Double,Double> IBitwiseOperators<TSelf,TSelf,TSelf> IComparisonOperators<Double,Double,Boolean> IComparisonOperators<TSelf,TSelf,Boolean> IDecrementOperators<Double> IDecrementOperators<TSelf> IDivisionOperators<Double,Double,Double> IDivisionOperators<TSelf,TSelf,TSelf> IEqualityOperators<Double,Double,Boolean> IEqualityOperators<TSelf,TOther,TResult> IEqualityOperators<TSelf,TSelf,Boolean> IExponentialFunctions<Double> IExponentialFunctions<TSelf> IFloatingPoint<Double> IFloatingPoint<TSelf> IFloatingPointConstants<Double> IFloatingPointConstants<TSelf> IFloatingPointIeee754<Double> IFloatingPointIeee754<TSelf> IHyperbolicFunctions<Double> IHyperbolicFunctions<TSelf> IIncrementOperators<Double> IIncrementOperators<TSelf> ILogarithmicFunctions<Double> ILogarithmicFunctions<TSelf> IMinMaxValue<Double> IModulusOperators<Double,Double,Double> IModulusOperators<TSelf,TSelf,TSelf> IMultiplicativeIdentity<Double,Double> IMultiplicativeIdentity<TSelf,TSelf> IMultiplyOperators<Double,Double,Double> IMultiplyOperators<TSelf,TSelf,TSelf> INumber<Double> INumber<TSelf> INumberBase<Double> INumberBase<TSelf> IPowerFunctions<Double> IPowerFunctions<TSelf> IRootFunctions<Double> IRootFunctions<TSelf> ISignedNumber<Double> ISignedNumber<TSelf> ISubtractionOperators<Double,Double,Double> ISubtractionOperators<TSelf,TSelf,TSelf> ITrigonometricFunctions<Double> ITrigonometricFunctions<TSelf> IUnaryNegationOperators<Double,Double> IUnaryNegationOperators<TSelf,TSelf> IUnaryPlusOperators<Double,Double> IUnaryPlusOperators<TSelf,TSelf>

예제

다음 코드 예제에서는 다음을 Double사용하는 방법을 보여 줍니다.

// The Temperature class stores the temperature as a Double
// and delegates most of the functionality to the Double
// implementation.
public class Temperature : IComparable, IFormattable
{
    // IComparable.CompareTo implementation.
    public int CompareTo(object obj) {
        if (obj == null) return 1;

        Temperature temp = obj as Temperature;
        if (obj != null)
            return m_value.CompareTo(temp.m_value);
        else
            throw new ArgumentException("object is not a Temperature");	
    }

    // IFormattable.ToString implementation.
    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);
    }

    // Parses the temperature from a string in the form
    // [ws][sign]digits['F|'C][ws]
    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;
        }
    }
}
// The Temperature class stores the temperature as a Double
// and delegates most of the functionality to the Double
// implementation.
type Temperature() =
    member val Value = 0. with get, set

    member this.Celsius
        with get () = (this.Value - 32.) / 1.8
        and set (value) =
            this.Value <- 1.8 * value + 32.

    // Parses the temperature from a string in the form
    // [ws][sign]digits['F|'C][ws]
    static member Parse(s: string, styles: NumberStyles, provider: IFormatProvider) =
        let temp = Temperature()

        if s.TrimEnd(null).EndsWith "'F" then
            temp.Value <- Double.Parse(s.Remove(s.LastIndexOf '\'', 2), styles, provider)
        elif s.TrimEnd(null).EndsWith "'C" then
            temp.Celsius <- Double.Parse(s.Remove(s.LastIndexOf '\'', 2), styles, provider)
        else
            temp.Value <- Double.Parse(s, styles, provider)
        temp

    interface IComparable with
        // IComparable.CompareTo implementation.
        member this.CompareTo(obj: obj) =
            match obj with 
            | null -> 1
            | :? Temperature as temp ->
                this.Value.CompareTo temp.Value
            | _ ->
                invalidArg "obj" "object is not a Temperature"

    interface IFormattable with
        // IFormattable.ToString implementation.
        member this.ToString(format: string, provider: IFormatProvider) =
            match format with
            | "F" ->
                $"{this.Value}'F"
            | "C" ->
                $"{this.Celsius}'C"
            | _ ->
                this.Value.ToString(format, provider)
' Temperature class stores the value as Double
' and delegates most of the functionality 
' to the Double implementation.
Public Class Temperature
    Implements IComparable, IFormattable

    Public Overloads Function CompareTo(ByVal obj As Object) As Integer _
        Implements IComparable.CompareTo

        If TypeOf obj Is Temperature Then
            Dim temp As Temperature = CType(obj, Temperature)

            Return m_value.CompareTo(temp.m_value)
        End If

        Throw New ArgumentException("object is not a Temperature")
    End Function

    Public Overloads Function ToString(ByVal format As String, ByVal provider As IFormatProvider) As String _
        Implements IFormattable.ToString

        If Not (format Is Nothing) Then
            If format.Equals("F") Then
                Return [String].Format("{0}'F", Me.Value.ToString())
            End If
            If format.Equals("C") Then
                Return [String].Format("{0}'C", Me.Celsius.ToString())
            End If
        End If

        Return m_value.ToString(format, provider)
    End Function

    ' Parses the temperature from a string in form
    ' [ws][sign]digits['F|'C][ws]
    Public Shared Function Parse(ByVal s As String, ByVal styles As NumberStyles, ByVal provider As IFormatProvider) As Temperature
        Dim temp As New Temperature()

        If s.TrimEnd().EndsWith("'F") Then
            temp.Value = Double.Parse(s.Remove(s.LastIndexOf("'"c), 2), styles, provider)
        Else
            If s.TrimEnd().EndsWith("'C") Then
                temp.Celsius = Double.Parse(s.Remove(s.LastIndexOf("'"c), 2), styles, provider)
            Else
                temp.Value = Double.Parse(s, styles, provider)
            End If
        End If
        Return temp
    End Function

    ' The value holder
    Protected m_value As Double

    Public Property Value() As Double
        Get
            Return m_value
        End Get
        Set(ByVal Value As Double)
            m_value = Value
        End Set
    End Property

    Public Property Celsius() As Double
        Get
            Return (m_value - 32) / 1.8
        End Get
        Set(ByVal Value As Double)
            m_value = Value * 1.8 + 32
        End Set
    End Property
End Class

설명

값 형식은 Double 음수 1.79769313486232e308에서 양수 1.79769313486232e308까지, 양수 또는 음수 0, PositiveInfinity, NegativeInfinity, 그리고 숫자가 아님(NaN)을 포함한 배정밀도 64비트 숫자를 나타냅니다. 매우 크거나(예: 행성이나 은하 사이의 거리) 또는 매우 작은 값(예: 킬로그램 단위의 물질의 분자 질량)을 나타내기 위한 것이며 종종 부정확합니다(예: 지구에서 다른 태양계까지의 거리). Double 형식은 이진 부동 소수점 산술 연산에 대한 IEC 60559:1989(IEEE 754) 표준을 준수합니다.

부동 소수점 표현 및 정밀도

데이터 형식은 Double 다음 표와 같이 배정밀도 부동 소수점 값을 64비트 이진 형식으로 저장합니다.

부품 비트
가수(Significand) 또는 맨티사(mantissa) 0-51
Exponent 52-62
기호(0 = 양수, 1 = 음수) 63

소수 자릿수가 일부 분수 값(예: 1/3 또는 Math.PI)을 정확하게 나타낼 수 없는 것처럼 이진 분수는 일부 소수 값을 나타낼 수 없습니다. 예를 들어 .1로 정확하게 10진수로 표현되는 1/10은 .001100110011 이진 분수로 표현되며 패턴 "0011"은 무한대로 반복됩니다. 이 경우 부동 소수점 값은 나타내는 숫자의 부정확한 표현을 제공합니다. 원래 부동 소수점 값에 대해 추가 수학 연산을 수행하면 정밀도가 부족한 경우가 많습니다. 예를 들어 .1을 10으로 곱하고 .1을 .1에서 .1로 9번 추가한 결과를 비교하면 8개의 작업이 더 포함되었기 때문에 정확도가 낮은 결과가 생성되었음을 알 수 있습니다. .NET 10 이전에는 두 개의 Double 값을 "R" 표준 숫자 형식 문자열을 사용하여 표시할 때, Double 형식이 지원하는 최대 17자리의 ~전체~ 자릿수 정확도가 드러나면서 이러한 차이가 분명해집니다.

using System;

public class Example13
{
    public static void Main()
    {
        Double value = .1;
        Double result1 = value * 10;
        Double result2 = 0;
        for (int ctr = 1; ctr <= 10; ctr++)
            result2 += value;

        Console.WriteLine($".1 * 10:           {result1:R}");
        Console.WriteLine($".1 Added 10 times: {result2:R}");
    }
}
// The example displays the following output:
//       .1 * 10:           1
//       .1 Added 10 times: 0.99999999999999989
let value = 0.1
let result1 = value * 10.
let mutable result2 = 0.
for i = 1 to 10 do
    result2 <- result2 + value

printfn $".1 * 10:           {result1:R}"
printfn $".1 Added 10 times: {result2:R}"
// The example displays the following output:
//       .1 * 10:           1
//       .1 Added 10 times: 0.99999999999999989
Module Example14
    Public Sub Run()
        Dim value As Double = 0.1
        Dim result1 As Double = value * 10
        Dim result2 As Double
        For ctr As Integer = 1 To 10
            result2 += value
        Next
        Console.WriteLine(".1 * 10:           {0:R}", result1)
        Console.WriteLine(".1 Added 10 times: {0:R}", result2)
    End Sub
End Module
' The example displays the following output:
'       .1 * 10:           1
'       .1 Added 10 times: 0.99999999999999989

일부 숫자는 소수점 이진 값으로 정확하게 나타낼 수 없으므로 부동 소수점 숫자는 실제 숫자와 근사치일 수 있습니다.

또한 모든 부동 소수점 숫자에는 제한된 수의 유효 자릿수가 있으며, 이는 부동 소수점 값이 실제 숫자와 근사치를 얼마나 정확하게 나타내는지도 결정합니다. Double 값의 전체 자릿수는 15자리이지만 내부적으로는 최대 17자리 자릿수가 유지됩니다. 즉, 일부 부동 소수점 연산에는 부동 소수점 값을 변경할 정밀도가 부족할 수 있습니다. 다음 예제에서 이에 대해 설명합니다. 매우 큰 부동 소수점 값을 정의한 다음, Double.Epsilon과 천조의 곱을 그것에 추가합니다. 그러나 제품이 너무 작아서 원래 부동 소수점 값을 수정할 수 없습니다. 가장 낮은 유효 자릿수는 천 번째인 반면 제품에서 가장 중요한 숫자는 10-309입니다.

using System;

public class Example14
{
    public static void Main()
    {
        Double value = 123456789012.34567;
        Double additional = Double.Epsilon * 1e15;
        Console.WriteLine($"{value} + {additional} = {value + additional}");
    }
}
// The example displays the following output:
//    123456789012.346 + 4.94065645841247E-309 = 123456789012.346
open System

let value = 123456789012.34567
let additional = Double.Epsilon * 1e15
printfn $"{value} + {additional} = {value + additional}"
// The example displays the following output:
//    123456789012.346 + 4.94065645841247E-309 = 123456789012.346
Module Example15
    Public Sub Run()
        Dim value As Double = 123456789012.34567
        Dim additional As Double = Double.Epsilon * 1.0E+15
        Console.WriteLine("{0} + {1} = {2}", value, additional,
                                           value + additional)
    End Sub
End Module
' The example displays the following output:
'   123456789012.346 + 4.94065645841247E-309 = 123456789012.346

부동 소수점 숫자의 제한된 정밀도에는 다음과 같은 몇 가지 결과가 있습니다.

  • 특정 정밀도에서는 동일하게 보이는 두 부동소수점 숫자가 가장 낮은 자리 숫자가 다르기 때문에 서로 같지 않을 수 있습니다. 다음 예제에서는 일련의 숫자가 함께 추가되고 해당 합계가 예상 합계와 비교됩니다.

    using System;
    
    public class Example10
    {
        public static void Main()
        {
            Double[] values = { 10.0, 2.88, 2.88, 2.88, 9.0 };
            Double result = 27.64;
            Double total = 0;
            foreach (var value in values)
                total += value;
    
            if (total.Equals(result))
                Console.WriteLine("The sum of the values equals the total.");
            else
                Console.WriteLine($"The sum of the values ({total}) does not equal the total ({result}).");
        }
    }
    // The example displays the following output:
    //      The sum of the values (36.64) does not equal the total (36.64).
    //
    // If the index items in the Console.WriteLine statement are changed to {0:R},
    // the example displays the following output:
    //       The sum of the values (27.639999999999997) does not equal the total (27.64).
    
    let values = [ 10.0; 2.88; 2.88; 2.88; 9.0 ]
    let result = 27.64
    let total = List.sum values
    
    if total.Equals result then
        printfn "The sum of the values equals the total."
    else
        printfn $"The sum of the values ({total}) does not equal the total ({result})."
    // The example displays the following output:
    //      The sum of the values (36.64) does not equal the total (36.64).
    //
    // If the index items in the Console.WriteLine statement are changed to {0:R},
    // the example displays the following output:
    //       The sum of the values (27.639999999999997) does not equal the total (27.64).
    
    Module Example11
        Public Sub Run()
            Dim values() As Double = {10.0, 2.88, 2.88, 2.88, 9.0}
            Dim result As Double = 27.64
            Dim total As Double
            For Each value In values
                total += value
            Next
            If total.Equals(result) Then
                Console.WriteLine("The sum of the values equals the total.")
            Else
                Console.WriteLine("The sum of the values ({0}) does not equal the total ({1}).",
                               total, result)
            End If
        End Sub
    End Module
    ' The example displays the following output:
    '      The sum of the values (36.64) does not equal the total (36.64).   
    '
    ' If the index items in the Console.WriteLine statement are changed to {0:R},
    ' the example displays the following output:
    '       The sum of the values (27.639999999999997) does not equal the total (27.64).
    

    두 값은 더하기 작업 중에 정밀도가 손실되어 같지 않습니다. 이 경우 비교를 수행하기 전에 Math.Round(Double, Int32) 메서드를 호출하여 Double 값을 원하는 전체 자릿수로 반올림하여 문제를 해결할 수 있습니다.

  • 부동 소수점 숫자를 사용하는 수학 또는 비교 연산은 이진 부동 소수점 숫자가 10진수와 같지 않을 수 있으므로 소수점 숫자를 사용하는 경우 동일한 결과를 생성하지 못할 수 있습니다. 이전 예제에서는 .1을 10으로 곱하고 .1을 곱한 결과를 표시하여 이를 설명했습니다.

    소수점 값을 가진 숫자 연산의 정확도가 중요한 경우 Decimal 형식을 사용하고 Double 형식은 사용하지 않는 것이 좋습니다. 정수 값이 형식 범위를 초과하는 숫자 연산의 Int128UInt128 정확도가 중요한 경우 형식을 BigInteger 사용합니다.

  • Single 값은 Double 값보다 정밀도가 낮습니다. Single 값이 표면상 동등한 Double 값으로 변환되더라도, 정밀도의 차이로 인해 Double 값과 동일하지 않은 경우가 많습니다. 다음 예제에서는 동일한 나누기 작업의 결과가 a DoubleSingle 값에 할당됩니다. Single 값이 Double캐스팅된 후 두 값을 비교하면 같지 않음이 표시됩니다.

    using System;
    
    public class Example9
    {
        public static void Run()
        {
            double value1 = 1 / 3.0;
            float sValue2 = 1 / 3.0f;
            double value2 = (double)sValue2;
            Console.WriteLine($"{value1:R} = {value2:R}: {value1.Equals(value2)}");
        }
    }
    
    // The example displays the following output:
    //        0.33333333333333331 = 0.3333333432674408: False
    
    open System
    
    let value1 = 1. / 3.
    let sValue2 = 1f /3f
    
    let value2 = double sValue2
    printfn $"{value1:R} = {value2:R}: {value1.Equals value2}"
    // The example displays the following output:
    //        0.33333333333333331 = 0.3333333432674408: False
    
    Module Example10
        Public Sub Run()
            Dim value1 As Double = 1 / 3
            Dim sValue2 As Single = 1 / 3
            Dim value2 As Double = CDbl(sValue2)
            Console.WriteLine("{0} = {1}: {2}", value1, value2, value1.Equals(value2))
        End Sub
    End Module
    ' The example displays the following output:
    '       0.33333333333333331 = 0.3333333432674408: False
    

    이 문제를 방지하려면 Double를 데이터 형식 Single 대신 사용하거나, 두 값의 정확도가 같아지도록 Round 메서드를 사용하십시오.

또한 Double 값을 사용한 산술 및 할당 연산의 결과는 Double 유형의 정밀도 손실로 인해 플랫폼에 따라 다소 차이가 있을 수 있습니다. 예를 들어 리터럴 Double 값을 할당한 결과는 32비트 및 64비트 버전의 .NET 다를 수 있습니다. 다음 예제에서는 리터럴 값 -4.423306042444772E-305와 값이 -4.423306042444772E-305인 변수가 변수에 Double 할당된 경우의 이 차이를 보여 줍니다. 이 경우 Parse(String) 메서드의 결과는 정밀도 손실이 없습니다.

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);

// 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
let value = -4.42330604244772E-305

let fromLiteral = -4.42330604244772E-305
let fromVariable = value
let fromParse = Double.Parse "-4.42330604244772E-305"

printfn $"Double value from literal: {fromLiteral,29:R}"
printfn $"Double value from variable: {fromVariable,28:R}"
printfn $"Double value from Parse method: {fromParse,24:R}"
// 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
Dim value As Double = -4.4233060424477198E-305

Dim fromLiteral As Double = -4.4233060424477198E-305
Dim fromVariable As Double = value
Dim fromParse As Double = 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)

' 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

동등성 테스트

같게 간주하려면 두 Double 값이 동일한 값을 나타내야 합니다. 그러나 값 간의 정밀도 차이 또는 하나 또는 두 값 모두에 의한 정밀도 손실로 인해 동일할 것으로 예상되는 부동 소수점 값은 가장 낮은 유효 자릿수의 차이로 인해 같지 않은 것으로 판명되는 경우가 많습니다. 따라서 두 값이 같은지 여부를 확인하기 위해 Equals 메서드를 호출하거나 두 CompareTo 값 간의 관계를 확인하기 위해 Double 메서드를 호출하면 예기치 않은 결과가 발생하는 경우가 많습니다. 이는 다음 예제에서 분명하게 알 수 있습니다. 첫 번째 값은 15자리의 정밀도를 가지고 두 번째 값은 17자리이므로 동일한 두 Double 값이 같지 않은 것으로 판명됩니다.

using System;

public class Example
{
   public static void Main()
   {
      double value1 = .333333333333333;
      double value2 = 1.0/3;
      Console.WriteLine($"{value1} = {value2}: {value1.Equals(value2)}");
   }
}
// The example displays the following output:
//        0.333333333333333 = 0.33333333333333331: False
open System

let value1 = 0.333333333333333
let value2 = 1. / 3.
printfn $"{value1:R} = {value2:R}: {value1.Equals value2}"
// The example displays the following output:
//        0.333333333333333 = 0.33333333333333331: False
Module Example1
    Public Sub Run()
        Dim value1 As Double = 0.333333333333333
        Dim value2 As Double = 1 / 3
        Console.WriteLine("{0} = {1}: {2}", value1, value2, value1.Equals(value2))
    End Sub
End Module

' The example displays the following output:
'       0.333333333333333 = 0.33333333333333331: False

정밀도 손실이 비교 결과에 영향을 미칠 가능성이 있는 경우, Equals 또는 CompareTo 메서드를 호출하는 대신 다음 대안 중 하나를 채택할 수 있습니다.

  • Math.Round 메서드를 호출하여 두 값의 정밀도가 같은지 확인합니다. 다음 예제에서는 두 개의 소수 값이 동일하도록 이 방법을 사용하도록 이전 예제를 수정합니다.

    double value1 = .333333333333333;
    double value2 = 1.0 / 3;
    int precision = 7;
    value1 = Math.Round(value1, precision);
    value2 = Math.Round(value2, precision);
    Console.WriteLine($"{value1} = {value2}: {value1.Equals(value2)}");
    
    // The example displays the following output:
    //        0.3333333 = 0.3333333: True
    
    open System
    
    let v1 = 0.333333333333333
    let v2 = 1. / 3.
    let precision = 7
    let value1 = Math.Round(v1, precision)
    let value2 = Math.Round(v2, precision)
    printfn $"{value1:R} = {value2:R}: {value1.Equals value2}"
    // The example displays the following output:
    //        0.3333333 = 0.3333333: True
    
    Module Example3
        Public Sub Run()
            Dim value1 As Double = 0.333333333333333
            Dim value2 As Double = 1 / 3
            Dim precision As Integer = 7
            value1 = Math.Round(value1, precision)
            value2 = Math.Round(value2, precision)
            Console.WriteLine("{0} = {1}: {2}", value1, value2, value1.Equals(value2))
        End Sub
    End Module
    
    ' The example displays the following output:
    '       0.3333333 = 0.3333333: True
    

    정밀도 문제는 여전히 중간점 값의 반올림에 적용됩니다. 자세한 내용은 Math.Round(Double, Int32, MidpointRounding) 메서드를 참조하세요.

  • 정확한 같음이 아닌 대략적인 같음을 테스트합니다. 이렇게 하려면 두 값이 다를 수 있지만 여전히 같을 수 있는 절대 크기를 정의하거나 더 작은 값이 더 큰 값과 다를 수 있는 상대 크기를 정의해야 합니다.

    Warning

    Double.Epsilon 같음을 테스트할 때 두 Double 값 사이의 거리를 절대 측정값으로 사용하는 경우가 있습니다. 그러나 Double.Epsilon는 값이 0인 Double에 더하거나 뺄 수 있는 가능한 가장 작은 값을 측정합니다. 대부분의 양수 및 음수 Double 값의 경우 Double.Epsilon 값이 너무 작아 검색할 수 없습니다. 따라서 0인 값을 제외하고 같음 테스트에는 사용하지 않는 것이 좋습니다.

    다음 예제에서는 후자의 방법을 사용하여 두 값 간의 상대적 차이를 테스트하는 IsApproximatelyEqual 메서드를 정의합니다. 이 메서드는 Math.Max(value1, value2)으로 나누어 두 값 중 절대값이 더 큰 값을 기준으로 상대적으로 비교하여, 결과가 올바른 크기의 순서에 놓이도록 합니다. 값 중 하나가 0이고 다른 하나가 음수인 경우 Math.Max가 0을 반환하면, 메서드는 Math.Min(value1, value2)로 대체되어 0이 아닌 값을 제수로 사용합니다. 또한 IsApproximatelyEqual 메서드 및 Equals(Double) 메서드에 대한 호출의 결과와 대조됩니다.

    using System;
    
    public class Example3
    {
        public static void Main()
        {
            double one1 = .1 * 10;
            double one2 = 0;
            for (int ctr = 1; ctr <= 10; ctr++)
                one2 += .1;
    
            Console.WriteLine($"{one1} = {one2}: {one1.Equals(one2)}");
            Console.WriteLine($"{one1} is approximately equal to {one2}: {IsApproximatelyEqual(one1, one2, .000000001)}");
        }
    
        static bool IsApproximatelyEqual(double value1, double value2, double epsilon)
        {
            // If they are equal anyway, just return True.
            if (value1.Equals(value2))
                return true;
    
            // Handle NaN, Infinity.
            if (Double.IsInfinity(value1) | Double.IsNaN(value1))
                return value1.Equals(value2);
            else if (Double.IsInfinity(value2) | Double.IsNaN(value2))
                return value1.Equals(value2);
    
            // Handle zero to avoid division by zero
            double divisor = Math.Max(value1, value2);
            if (divisor.Equals(0))
                divisor = Math.Min(value1, value2);
    
            return Math.Abs((value1 - value2) / divisor) <= epsilon;
        }
    }
    
    // The example displays the following output:
    //       1 = 0.99999999999999989: False
    //       1 is approximately equal to 0.99999999999999989: True
    
    open System
    
    let isApproximatelyEqual (value1: double) (value2: double) (epsilon: double) =
        // If they are equal anyway, just return True.
        if value1.Equals value2 then 
            true
        else
            // Handle NaN, Infinity.
            if Double.IsInfinity value1 || Double.IsNaN value1 then 
                value1.Equals value2
            elif Double.IsInfinity value2 || Double.IsNaN value2 then
                value1.Equals value2
            else
                // Handle zero to avoid division by zero
                let divisor = max value1 value2
                let divisor = 
                    if divisor.Equals 0 then
                        min value1 value2
                    else 
                        divisor
                abs ((value1 - value2) / divisor) <= epsilon
    
    let one1 = 0.1 * 10.
    let mutable one2 = 0.
    for _ = 1 to 10 do
        one2 <- one2 + 0.1
    
    printfn $"{one1:R} = {one2:R}: {one1.Equals one2}"
    printfn $"{one1:R} is approximately equal to {one2:R}: {isApproximatelyEqual one1 one2 0.000000001}"
    
    // The example displays the following output:
    //       1 = 0.99999999999999989: False
    //       1 is approximately equal to 0.99999999999999989: True
    
    Module Example4
        Public Sub Run()
            Dim one1 As Double = 0.1 * 10
            Dim one2 As Double = 0
            For ctr As Integer = 1 To 10
                one2 += 0.1
            Next
            Console.WriteLine("{0} = {1}: {2}", one1, one2, one1.Equals(one2))
            Console.WriteLine("{0} is approximately equal to {1}: {2}",
                            one1, one2,
                            IsApproximatelyEqual(one1, one2, 0.000000001))
        End Sub
    
        Function IsApproximatelyEqual(value1 As Double, value2 As Double,
                                     epsilon As Double) As Boolean
            ' If they are equal anyway, just return True.
            If value1.Equals(value2) Then Return True
    
            ' Handle NaN, Infinity.
            If Double.IsInfinity(value1) Or Double.IsNaN(value1) Then
                Return value1.Equals(value2)
            ElseIf Double.IsInfinity(value2) Or Double.IsNaN(value2) Then
                Return value1.Equals(value2)
            End If
    
            ' Handle zero to avoid division by zero
            Dim divisor As Double = Math.Max(value1, value2)
            If divisor.Equals(0) Then
                divisor = Math.Min(value1, value2)
            End If
    
            Return Math.Abs((value1 - value2) / divisor) <= epsilon
        End Function
    End Module
    
    ' The example displays the following output:
    '       1 = 0.99999999999999989: False
    '       1 is approximately equal to 0.99999999999999989: True
    

부동 소수점 값 및 예외

정수 계열 형식의 연산은 0으로 나눌 때 DivideByZeroException 예외를, 오버플로 시 OverflowException 예외를 검사된 컨텍스트에서 throw하는 것과 달리, 부동 소수점 값과 관련된 연산은 예외를 throw하지 않습니다. 대신 예외적인 상황에서 부동 소수점 연산의 결과는 0, 양수 무한대, 음의 무한대 또는 숫자(NaN)가 아닙니다.

  • 부동 소수점 연산의 결과가 대상 형식에 비해 너무 작으면 결과는 0입니다. 이 문제는 다음 예제와 같이 두 개의 매우 작은 숫자를 곱할 때 발생할 수 있습니다.

    using System;
    
    public class Example6
    {
        public static void Main()
        {
            Double value1 = 1.1632875981534209e-225;
            Double value2 = 9.1642346778e-175;
            Double result = value1 * value2;
            Console.WriteLine($"{value1} * {value2} = {result}");
            Console.WriteLine($"{result} = 0: {result.Equals(0.0)}");
        }
    }
    // The example displays the following output:
    //       1.16328759815342E-225 * 9.1642346778E-175 = 0
    //       0 = 0: True
    
    let value1 = 1.1632875981534209e-225
    let value2 = 9.1642346778e-175
    let result = value1 * value2
    printfn $"{value1} * {value2} = {result}"
    printfn $"{result} = 0: {result.Equals 0.0}"
    // The example displays the following output:
    //       1.16328759815342E-225 * 9.1642346778E-175 = 0
    //       0 = 0: True
    
    Module Example7
        Public Sub Run()
            Dim value1 As Double = 1.1632875981534209E-225
            Dim value2 As Double = 9.1642346778E-175
            Dim result As Double = value1 * value2
            Console.WriteLine("{0} * {1} = {2}", value1, value2, result)
            Console.WriteLine("{0} = 0: {1}", result, result.Equals(0.0))
        End Sub
    End Module
    ' The example displays the following output:
    '       1.16328759815342E-225 * 9.1642346778E-175 = 0
    '       0 = 0: True
    
  • 부동 소수점 연산 결과의 크기가 대상 형식의 범위를 초과하는 경우, 결과의 부호에 따라 연산의 결과는 PositiveInfinity 또는 NegativeInfinity이 됩니다. 어떤 작업이 Double.MaxValue에서 오버플로하면 그 결과는 PositiveInfinity이고, Double.MinValue에서 오버플로하는 작업의 결과는 NegativeInfinity입니다. 이는 다음 예제에서 볼 수 있습니다.

    using System;
    
    public class Example7
    {
        public static void Main()
        {
            Double value1 = 4.565e153;
            Double value2 = 6.9375e172;
            Double result = value1 * value2;
            Console.WriteLine($"PositiveInfinity: {Double.IsPositiveInfinity(result)}");
            Console.WriteLine($"NegativeInfinity: {Double.IsNegativeInfinity(result)}{Environment.NewLine}");
    
            value1 = -value1;
            result = value1 * value2;
            Console.WriteLine($"PositiveInfinity: {Double.IsPositiveInfinity(result)}");
            Console.WriteLine($"NegativeInfinity: {Double.IsNegativeInfinity(result)}");
        }
    }
    
    // The example displays the following output:
    //       PositiveInfinity: True
    //       NegativeInfinity: False
    //
    //       PositiveInfinity: False
    //       NegativeInfinity: True
    
    open System
    
    let value1 = 4.565e153
    let value2 = 6.9375e172
    let result = value1 * value2
    printfn $"PositiveInfinity: {Double.IsPositiveInfinity result}"
    printfn $"NegativeInfinity: {Double.IsNegativeInfinity result}\n"
    
    let value3 = - value1
    let result2 = value2 * value3
    printfn $"PositiveInfinity: {Double.IsPositiveInfinity result2}"
    printfn $"NegativeInfinity: {Double.IsNegativeInfinity result2}"
    
    // The example displays the following output:
    //       PositiveInfinity: True
    //       NegativeInfinity: False
    //
    //       PositiveInfinity: False
    //       NegativeInfinity: True
    
    Module Example8
        Public Sub Run()
            Dim value1 As Double = 4.565E+153
            Dim value2 As Double = 6.9375E+172
            Dim result As Double = value1 * value2
            Console.WriteLine("PositiveInfinity: {0}",
                             Double.IsPositiveInfinity(result))
            Console.WriteLine("NegativeInfinity: {0}",
                            Double.IsNegativeInfinity(result))
            Console.WriteLine()
            value1 = -value1
            result = value1 * value2
            Console.WriteLine("PositiveInfinity: {0}",
                             Double.IsPositiveInfinity(result))
            Console.WriteLine("NegativeInfinity: {0}",
                            Double.IsNegativeInfinity(result))
        End Sub
    End Module
    ' The example displays the following output:
    '       PositiveInfinity: True
    '       NegativeInfinity: False
    '       
    '       PositiveInfinity: False
    '       NegativeInfinity: True
    

    PositiveInfinity 또한 양의 배수를 0으로 나누기에서 비롯된 결과이며, NegativeInfinity은 음의 배수를 0으로 나누기에서 비롯된 결과입니다.

  • 부동 소수점 연산이 유효하지 않으면 그 연산의 결과는 NaN입니다. 예를 들어, 다음 연산의 결과는 NaN입니다.

    • 배당금이 0인 0으로 나누기. 다른 경우에 0으로 나누면 PositiveInfinity 또는 NegativeInfinity이 발생할 수 있음을 유의하십시오.

    • 잘못된 입력이 있는 모든 부동 소수점 작업. 예를 들어 음수 Math.Sqrt 값으로 메서드를 호출하면 1보다 크거나 음수 NaN 보다 작은 값으로 메서드를 호출하는 것과 마찬가지로 반환Math.Acos됩니다.

    • 값이 Double.NaN인수가 있는 모든 연산입니다.

타입 변환

Double 구조체는 명시적 또는 암시적 변환 연산자를 정의하지 않습니다. 대신 변환은 컴파일러에 의해 구현됩니다.

기본 숫자 형식의 값을 a Double 로 변환하는 것은 확대 변환이므로 컴파일러가 명시적으로 요구하지 않는 한 명시적 캐스트 연산자 또는 변환 메서드 호출이 필요하지 않습니다. 예를 들어 C# 컴파일러는 Decimal에서 Double로의 변환에 캐스팅 연산자가 필요하지만, Visual Basic 컴파일러는 그렇지 않습니다. 다음 예제에서는 다른 기본 숫자 형식의 최소값 또는 최대값을 로 Double변환합니다.

dynamic[] values = { Byte.MinValue, Byte.MaxValue, Decimal.MinValue,
                   Decimal.MaxValue, Int16.MinValue, Int16.MaxValue,
                   Int32.MinValue, Int32.MaxValue, Int64.MinValue,
                   Int64.MaxValue, SByte.MinValue, SByte.MaxValue,
                   Single.MinValue, Single.MaxValue, UInt16.MinValue,
                   UInt16.MaxValue, UInt32.MinValue, UInt32.MaxValue,
                   UInt64.MinValue, UInt64.MaxValue };
double dblValue;
foreach (dynamic value in values)
{
    if (value.GetType() == typeof(decimal))
        dblValue = (double)value;
    else
        dblValue = value;
    Console.WriteLine($"{value} ({value.GetType().Name}) --> " +
        $"{dblValue:R} ({dblValue.GetType().Name})");
}

// The example displays the following output:
//    0 (Byte) --> 0 (Double)
//    255 (Byte) --> 255 (Double)
//    -79228162514264337593543950335 (Decimal) --> -7.9228162514264338E+28 (Double)
//    79228162514264337593543950335 (Decimal) --> 7.9228162514264338E+28 (Double)
//    -32768 (Int16) --> -32768 (Double)
//    32767 (Int16) --> 32767 (Double)
//    -2147483648 (Int32) --> -2147483648 (Double)
//    2147483647 (Int32) --> 2147483647 (Double)
//    -9223372036854775808 (Int64) --> -9.2233720368547758E+18 (Double)
//    9223372036854775807 (Int64) --> 9.2233720368547758E+18 (Double)
//    -128 (SByte) --> -128 (Double)
//    127 (SByte) --> 127 (Double)
//    -3.402823E+38 (Single) --> -3.4028234663852886E+38 (Double)
//    3.402823E+38 (Single) --> 3.4028234663852886E+38 (Double)
//    0 (UInt16) --> 0 (Double)
//    65535 (UInt16) --> 65535 (Double)
//    0 (UInt32) --> 0 (Double)
//    4294967295 (UInt32) --> 4294967295 (Double)
//    0 (UInt64) --> 0 (Double)
//    18446744073709551615 (UInt64) --> 1.8446744073709552E+19 (Double)
open System

let values: obj[] = 
    [| Byte.MinValue; Byte.MaxValue; Decimal.MinValue
       Decimal.MaxValue; Int16.MinValue; Int16.MaxValue
       Int32.MinValue; Int32.MaxValue; Int64.MinValue
       Int64.MaxValue; SByte.MinValue; SByte.MaxValue
       Single.MinValue; Single.MaxValue; UInt16.MinValue
       UInt16.MaxValue; UInt32.MinValue, UInt32.MaxValue
       UInt64.MinValue; UInt64.MaxValue |]

for value in values do
    let dblValue = value :?> double
    printfn $"{value} ({value.GetType().Name}) --> {dblValue:R} ({dblValue.GetType().Name})"
// The example displays the following output:
//    0 (Byte) --> 0 (Double)
//    255 (Byte) --> 255 (Double)
//    -79228162514264337593543950335 (Decimal) --> -7.9228162514264338E+28 (Double)
//    79228162514264337593543950335 (Decimal) --> 7.9228162514264338E+28 (Double)
//    -32768 (Int16) --> -32768 (Double)
//    32767 (Int16) --> 32767 (Double)
//    -2147483648 (Int32) --> -2147483648 (Double)
//    2147483647 (Int32) --> 2147483647 (Double)
//    -9223372036854775808 (Int64) --> -9.2233720368547758E+18 (Double)
//    9223372036854775807 (Int64) --> 9.2233720368547758E+18 (Double)
//    -128 (SByte) --> -128 (Double)
//    127 (SByte) --> 127 (Double)
//    -3.402823E+38 (Single) --> -3.4028234663852886E+38 (Double)
//    3.402823E+38 (Single) --> 3.4028234663852886E+38 (Double)
//    0 (UInt16) --> 0 (Double)
//    65535 (UInt16) --> 65535 (Double)
//    0 (UInt32) --> 0 (Double)
//    4294967295 (UInt32) --> 4294967295 (Double)
//    0 (UInt64) --> 0 (Double)
//    18446744073709551615 (UInt64) --> 1.8446744073709552E+19 (Double)
Module Example5
    Public Sub Run()
        Dim values() As Object = {Byte.MinValue, Byte.MaxValue, Decimal.MinValue,
                                 Decimal.MaxValue, Int16.MinValue, Int16.MaxValue,
                                 Int32.MinValue, Int32.MaxValue, Int64.MinValue,
                                 Int64.MaxValue, SByte.MinValue, SByte.MaxValue,
                                 Single.MinValue, Single.MaxValue, UInt16.MinValue,
                                 UInt16.MaxValue, UInt32.MinValue, UInt32.MaxValue,
                                 UInt64.MinValue, UInt64.MaxValue}
        Dim dblValue As Double
        For Each value In values
            dblValue = value
            Console.WriteLine("{0} ({1}) --> {2:R} ({3})",
                           value, value.GetType().Name,
                           dblValue, dblValue.GetType().Name)
        Next
    End Sub
End Module
' The example displays the following output:
'    0 (Byte) --> 0 (Double)
'    255 (Byte) --> 255 (Double)
'    -79228162514264337593543950335 (Decimal) --> -7.9228162514264338E+28 (Double)
'    79228162514264337593543950335 (Decimal) --> 7.9228162514264338E+28 (Double)
'    -32768 (Int16) --> -32768 (Double)
'    32767 (Int16) --> 32767 (Double)
'    -2147483648 (Int32) --> -2147483648 (Double)
'    2147483647 (Int32) --> 2147483647 (Double)
'    -9223372036854775808 (Int64) --> -9.2233720368547758E+18 (Double)
'    9223372036854775807 (Int64) --> 9.2233720368547758E+18 (Double)
'    -128 (SByte) --> -128 (Double)
'    127 (SByte) --> 127 (Double)
'    -3.402823E+38 (Single) --> -3.4028234663852886E+38 (Double)
'    3.402823E+38 (Single) --> 3.4028234663852886E+38 (Double)
'    0 (UInt16) --> 0 (Double)
'    65535 (UInt16) --> 65535 (Double)
'    0 (UInt32) --> 0 (Double)
'    4294967295 (UInt32) --> 4294967295 (Double)
'    0 (UInt64) --> 0 (Double)
'    18446744073709551615 (UInt64) --> 1.8446744073709552E+19 (Double)

또한 SingleSingle.NaN, Single.PositiveInfinitySingle.NegativeInfinity은 각각 Double.NaN, Double.PositiveInfinityDouble.NegativeInfinity으로 변환됩니다.

일부 숫자 형식의 값을 Double 값으로 변환하면 정밀도가 떨어질 수 있습니다. 예시에서 설명하듯이 Decimal, Int64, 및 UInt64 값을 Double 값으로 변환할 때 정밀도 손실이 발생할 수 있습니다.

Double 값을 다른 기본 숫자 데이터 형식의 값으로 변환하려면 축소 변환이며 캐스트 연산자(C#), 변환 메서드(Visual Basic) 또는 Convert 메서드 호출이 필요합니다. 대상 형식의 MinValueMaxValue 속성으로 정의된 대상 데이터 형식의 범위를 벗어난 값은 다음 표와 같이 동작합니다.

대상 유형 Result
모든 정수 계열 형식 확인된 컨텍스트에서 변환이 발생하는 경우 OverflowException 예외입니다.

확인되지 않은 컨텍스트(C#의 기본값)에서 변환이 발생하면 변환 작업이 성공하지만 값이 오버플로됩니다.
Decimal 예외입니다 OverflowException .
Single Single.NegativeInfinity 음수 값의 경우

Single.PositiveInfinity 양수 값에 대해.

또한 Double.NaN, Double.PositiveInfinityDouble.NegativeInfinity는 확인된 컨텍스트에서 정수로 변환하기 위한 OverflowException을 던지지만, 이러한 값은 확인되지 않은 컨텍스트에서 정수로 변환될 때 오버플로가 발생합니다. Decimal변환을 할 때는 항상 OverflowException를 던집니다. Single변환의 경우 각각 Single.NaN, Single.PositiveInfinitySingle.NegativeInfinity변환합니다.

정밀도 손실은 Double 값을 다른 숫자 형식으로 변환할 때 발생할 수 있습니다. 예제의 출력에서 볼 수 있듯이 정수 형식으로 변환할 경우, 값이 반올림되거나(Visual Basic에서와 같이) 잘리면(C#에서와 같이) 소수 구성 요소가 손실됩니다. Double. 두 값 DecimalSingle로 변환할 때, Double 값이 대상 데이터 형식에 정확하게 표현되지 않을 수 있습니다.

다음 예제에서는 여러 Double 값을 다른 여러 숫자 형식으로 변환합니다. 변환은 Visual Basic(기본값), C#(확인된 키워드로 인해) 및 F#( 확인된 모듈로 인해)의 확인된 컨텍스트에서 발생합니다. 예제의 출력은 확인된 선택되지 않은 컨텍스트 모두에서 변환 결과를 보여 줍니다. Visual Basic에서 /removeintchecks+ 컴파일러 스위치를 사용하여 컴파일하고, C#에서 checked 문을 주석 처리하고, F#에서 open Checked 문을 주석 처리하여 확인되지 않은 컨텍스트에서 변환을 수행할 수 있습니다.

using System;

public class Example5
{
    public static void Main()
    {
        Double[] values = { Double.MinValue, -67890.1234, -12345.6789,
                          12345.6789, 67890.1234, Double.MaxValue,
                          Double.NaN, Double.PositiveInfinity,
                          Double.NegativeInfinity };
        checked
        {
            foreach (var value in values)
            {
                try
                {
                    Int64 lValue = (long)value;
                    Console.WriteLine($"{value} ({value.GetType().Name}) --> {lValue} (0x{lValue:X16}) ({lValue.GetType().Name})");
                }
                catch (OverflowException)
                {
                    Console.WriteLine($"Unable to convert {value} to Int64.");
                }
                try
                {
                    UInt64 ulValue = (ulong)value;
                    Console.WriteLine($"{value} ({value.GetType().Name}) --> {ulValue} (0x{ulValue:X16}) ({ulValue.GetType().Name})");
                }
                catch (OverflowException)
                {
                    Console.WriteLine($"Unable to convert {value} to UInt64.");
                }
                try
                {
                    Decimal dValue = (decimal)value;
                    Console.WriteLine($"{value} ({value.GetType().Name}) --> {dValue} ({dValue.GetType().Name})");
                }
                catch (OverflowException)
                {
                    Console.WriteLine($"Unable to convert {value} to Decimal.");
                }
                try
                {
                    Single sValue = (float)value;
                    Console.WriteLine($"{value} ({value.GetType().Name}) --> {sValue} ({sValue.GetType().Name})");
                }
                catch (OverflowException)
                {
                    Console.WriteLine($"Unable to convert {value} to Single.");
                }
                Console.WriteLine();
            }
        }
    }
}
// The example displays the following output for conversions performed
// in a checked context:
//       Unable to convert -1.79769313486232E+308 to Int64.
//       Unable to convert -1.79769313486232E+308 to UInt64.
//       Unable to convert -1.79769313486232E+308 to Decimal.
//       -1.79769313486232E+308 (Double) --> -Infinity (Single)
//
//       -67890.1234 (Double) --> -67890 (0xFFFFFFFFFFFEF6CE) (Int64)
//       Unable to convert -67890.1234 to UInt64.
//       -67890.1234 (Double) --> -67890.1234 (Decimal)
//       -67890.1234 (Double) --> -67890.13 (Single)
//
//       -12345.6789 (Double) --> -12345 (0xFFFFFFFFFFFFCFC7) (Int64)
//       Unable to convert -12345.6789 to UInt64.
//       -12345.6789 (Double) --> -12345.6789 (Decimal)
//       -12345.6789 (Double) --> -12345.68 (Single)
//
//       12345.6789 (Double) --> 12345 (0x0000000000003039) (Int64)
//       12345.6789 (Double) --> 12345 (0x0000000000003039) (UInt64)
//       12345.6789 (Double) --> 12345.6789 (Decimal)
//       12345.6789 (Double) --> 12345.68 (Single)
//
//       67890.1234 (Double) --> 67890 (0x0000000000010932) (Int64)
//       67890.1234 (Double) --> 67890 (0x0000000000010932) (UInt64)
//       67890.1234 (Double) --> 67890.1234 (Decimal)
//       67890.1234 (Double) --> 67890.13 (Single)
//
//       Unable to convert 1.79769313486232E+308 to Int64.
//       Unable to convert 1.79769313486232E+308 to UInt64.
//       Unable to convert 1.79769313486232E+308 to Decimal.
//       1.79769313486232E+308 (Double) --> Infinity (Single)
//
//       Unable to convert NaN to Int64.
//       Unable to convert NaN to UInt64.
//       Unable to convert NaN to Decimal.
//       NaN (Double) --> NaN (Single)
//
//       Unable to convert Infinity to Int64.
//       Unable to convert Infinity to UInt64.
//       Unable to convert Infinity to Decimal.
//       Infinity (Double) --> Infinity (Single)
//
//       Unable to convert -Infinity to Int64.
//       Unable to convert -Infinity to UInt64.
//       Unable to convert -Infinity to Decimal.
//       -Infinity (Double) --> -Infinity (Single)
// The example displays the following output for conversions performed
// in an unchecked context:
//       -1.79769313486232E+308 (Double) --> -9223372036854775808 (0x8000000000000000) (Int64)
//       -1.79769313486232E+308 (Double) --> 9223372036854775808 (0x8000000000000000) (UInt64)
//       Unable to convert -1.79769313486232E+308 to Decimal.
//       -1.79769313486232E+308 (Double) --> -Infinity (Single)
//
//       -67890.1234 (Double) --> -67890 (0xFFFFFFFFFFFEF6CE) (Int64)
//       -67890.1234 (Double) --> 18446744073709483726 (0xFFFFFFFFFFFEF6CE) (UInt64)
//       -67890.1234 (Double) --> -67890.1234 (Decimal)
//       -67890.1234 (Double) --> -67890.13 (Single)
//
//       -12345.6789 (Double) --> -12345 (0xFFFFFFFFFFFFCFC7) (Int64)
//       -12345.6789 (Double) --> 18446744073709539271 (0xFFFFFFFFFFFFCFC7) (UInt64)
//       -12345.6789 (Double) --> -12345.6789 (Decimal)
//       -12345.6789 (Double) --> -12345.68 (Single)
//
//       12345.6789 (Double) --> 12345 (0x0000000000003039) (Int64)
//       12345.6789 (Double) --> 12345 (0x0000000000003039) (UInt64)
//       12345.6789 (Double) --> 12345.6789 (Decimal)
//       12345.6789 (Double) --> 12345.68 (Single)
//
//       67890.1234 (Double) --> 67890 (0x0000000000010932) (Int64)
//       67890.1234 (Double) --> 67890 (0x0000000000010932) (UInt64)
//       67890.1234 (Double) --> 67890.1234 (Decimal)
//       67890.1234 (Double) --> 67890.13 (Single)
//
//       1.79769313486232E+308 (Double) --> -9223372036854775808 (0x8000000000000000) (Int64)
//       1.79769313486232E+308 (Double) --> 0 (0x0000000000000000) (UInt64)
//       Unable to convert 1.79769313486232E+308 to Decimal.
//       1.79769313486232E+308 (Double) --> Infinity (Single)
//
//       NaN (Double) --> -9223372036854775808 (0x8000000000000000) (Int64)
//       NaN (Double) --> 0 (0x0000000000000000) (UInt64)
//       Unable to convert NaN to Decimal.
//       NaN (Double) --> NaN (Single)
//
//       Infinity (Double) --> -9223372036854775808 (0x8000000000000000) (Int64)
//       Infinity (Double) --> 0 (0x0000000000000000) (UInt64)
//       Unable to convert Infinity to Decimal.
//       Infinity (Double) --> Infinity (Single)
//
//       -Infinity (Double) --> -9223372036854775808 (0x8000000000000000) (Int64)
//       -Infinity (Double) --> 9223372036854775808 (0x8000000000000000) (UInt64)
//       Unable to convert -Infinity to Decimal.
//       -Infinity (Double) --> -Infinity (Single)
open System
open Checked

let values = 
    [| Double.MinValue; -67890.1234; -12345.6789
       12345.6789; 67890.1234; Double.MaxValue
       Double.NaN; Double.PositiveInfinity;
       Double.NegativeInfinity |]

for value in values do
    try
        let lValue = int64 value
        printfn $"{value} ({value.GetType().Name}) --> {lValue} (0x{lValue:X16}) ({lValue.GetType().Name})"
    with :? OverflowException ->
        printfn $"Unable to convert {value} to Int64."
    try
        let ulValue = uint64 value
        printfn $"{value} ({value.GetType().Name}) --> {ulValue} (0x{ulValue:X16}) ({ulValue.GetType().Name})"
    with :? OverflowException ->
        printfn $"Unable to convert {value} to UInt64."
    try
        let dValue = decimal value
        printfn $"{value} ({value.GetType().Name}) --> {dValue} ({dValue.GetType().Name})"
    with :? OverflowException ->
        printfn $"Unable to convert {value} to Decimal."
    try
        let sValue = float32 value
        printfn $"{value} ({value.GetType().Name}) --> {sValue} ({sValue.GetType().Name})"
    with :? OverflowException ->
        printfn $"Unable to convert {value} to Single."
    printfn ""
// The example displays the following output for conversions performed
// in a checked context:
//       Unable to convert -1.79769313486232E+308 to Int64.
//       Unable to convert -1.79769313486232E+308 to UInt64.
//       Unable to convert -1.79769313486232E+308 to Decimal.
//       -1.79769313486232E+308 (Double) --> -Infinity (Single)
//
//       -67890.1234 (Double) --> -67890 (0xFFFFFFFFFFFEF6CE) (Int64)
//       Unable to convert -67890.1234 to UInt64.
//       -67890.1234 (Double) --> -67890.1234 (Decimal)
//       -67890.1234 (Double) --> -67890.13 (Single)
//
//       -12345.6789 (Double) --> -12345 (0xFFFFFFFFFFFFCFC7) (Int64)
//       Unable to convert -12345.6789 to UInt64.
//       -12345.6789 (Double) --> -12345.6789 (Decimal)
//       -12345.6789 (Double) --> -12345.68 (Single)
//
//       12345.6789 (Double) --> 12345 (0x0000000000003039) (Int64)
//       12345.6789 (Double) --> 12345 (0x0000000000003039) (UInt64)
//       12345.6789 (Double) --> 12345.6789 (Decimal)
//       12345.6789 (Double) --> 12345.68 (Single)
//
//       67890.1234 (Double) --> 67890 (0x0000000000010932) (Int64)
//       67890.1234 (Double) --> 67890 (0x0000000000010932) (UInt64)
//       67890.1234 (Double) --> 67890.1234 (Decimal)
//       67890.1234 (Double) --> 67890.13 (Single)
//
//       Unable to convert 1.79769313486232E+308 to Int64.
//       Unable to convert 1.79769313486232E+308 to UInt64.
//       Unable to convert 1.79769313486232E+308 to Decimal.
//       1.79769313486232E+308 (Double) --> Infinity (Single)
//
//       Unable to convert NaN to Int64.
//       Unable to convert NaN to UInt64.
//       Unable to convert NaN to Decimal.
//       NaN (Double) --> NaN (Single)
//
//       Unable to convert Infinity to Int64.
//       Unable to convert Infinity to UInt64.
//       Unable to convert Infinity to Decimal.
//       Infinity (Double) --> Infinity (Single)
//
//       Unable to convert -Infinity to Int64.
//       Unable to convert -Infinity to UInt64.
//       Unable to convert -Infinity to Decimal.
//       -Infinity (Double) --> -Infinity (Single)
// The example displays the following output for conversions performed
// in an unchecked context:
//       -1.79769313486232E+308 (Double) --> -9223372036854775808 (0x8000000000000000) (Int64)
//       -1.79769313486232E+308 (Double) --> 9223372036854775808 (0x8000000000000000) (UInt64)
//       Unable to convert -1.79769313486232E+308 to Decimal.
//       -1.79769313486232E+308 (Double) --> -Infinity (Single)
//
//       -67890.1234 (Double) --> -67890 (0xFFFFFFFFFFFEF6CE) (Int64)
//       -67890.1234 (Double) --> 18446744073709483726 (0xFFFFFFFFFFFEF6CE) (UInt64)
//       -67890.1234 (Double) --> -67890.1234 (Decimal)
//       -67890.1234 (Double) --> -67890.13 (Single)
//
//       -12345.6789 (Double) --> -12345 (0xFFFFFFFFFFFFCFC7) (Int64)
//       -12345.6789 (Double) --> 18446744073709539271 (0xFFFFFFFFFFFFCFC7) (UInt64)
//       -12345.6789 (Double) --> -12345.6789 (Decimal)
//       -12345.6789 (Double) --> -12345.68 (Single)
//
//       12345.6789 (Double) --> 12345 (0x0000000000003039) (Int64)
//       12345.6789 (Double) --> 12345 (0x0000000000003039) (UInt64)
//       12345.6789 (Double) --> 12345.6789 (Decimal)
//       12345.6789 (Double) --> 12345.68 (Single)
//
//       67890.1234 (Double) --> 67890 (0x0000000000010932) (Int64)
//       67890.1234 (Double) --> 67890 (0x0000000000010932) (UInt64)
//       67890.1234 (Double) --> 67890.1234 (Decimal)
//       67890.1234 (Double) --> 67890.13 (Single)
//
//       1.79769313486232E+308 (Double) --> -9223372036854775808 (0x8000000000000000) (Int64)
//       1.79769313486232E+308 (Double) --> 0 (0x0000000000000000) (UInt64)
//       Unable to convert 1.79769313486232E+308 to Decimal.
//       1.79769313486232E+308 (Double) --> Infinity (Single)
//
//       NaN (Double) --> -9223372036854775808 (0x8000000000000000) (Int64)
//       NaN (Double) --> 0 (0x0000000000000000) (UInt64)
//       Unable to convert NaN to Decimal.
//       NaN (Double) --> NaN (Single)
//
//       Infinity (Double) --> -9223372036854775808 (0x8000000000000000) (Int64)
//       Infinity (Double) --> 0 (0x0000000000000000) (UInt64)
//       Unable to convert Infinity to Decimal.
//       Infinity (Double) --> Infinity (Single)
//
//       -Infinity (Double) --> -9223372036854775808 (0x8000000000000000) (Int64)
//       -Infinity (Double) --> 9223372036854775808 (0x8000000000000000) (UInt64)
//       Unable to convert -Infinity to Decimal.
//       -Infinity (Double) --> -Infinity (Single)
Module Example6
    Public Sub Run()
        Dim values() As Double = {Double.MinValue, -67890.1234, -12345.6789,
                                 12345.6789, 67890.1234, Double.MaxValue,
                                 Double.NaN, Double.PositiveInfinity,
                                 Double.NegativeInfinity}
        For Each value In values
            Try
                Dim lValue As Int64 = CLng(value)
                Console.WriteLine("{0} ({1}) --> {2} (0x{2:X16}) ({3})",
                               value, value.GetType().Name,
                               lValue, lValue.GetType().Name)
            Catch e As OverflowException
                Console.WriteLine("Unable to convert {0} to Int64.", value)
            End Try
            Try
                Dim ulValue As UInt64 = CULng(value)
                Console.WriteLine("{0} ({1}) --> {2} (0x{2:X16}) ({3})",
                               value, value.GetType().Name,
                               ulValue, ulValue.GetType().Name)
            Catch e As OverflowException
                Console.WriteLine("Unable to convert {0} to UInt64.", value)
            End Try
            Try
                Dim dValue As Decimal = CDec(value)
                Console.WriteLine("{0} ({1}) --> {2} ({3})",
                               value, value.GetType().Name,
                               dValue, dValue.GetType().Name)
            Catch e As OverflowException
                Console.WriteLine("Unable to convert {0} to Decimal.", value)
            End Try
            Try
                Dim sValue As Single = CSng(value)
                Console.WriteLine("{0} ({1}) --> {2} ({3})",
                               value, value.GetType().Name,
                               sValue, sValue.GetType().Name)
            Catch e As OverflowException
                Console.WriteLine("Unable to convert {0} to Single.", value)
            End Try
            Console.WriteLine()
        Next
    End Sub
End Module
' The example displays the following output for conversions performed
' in a checked context:
'       Unable to convert -1.79769313486232E+308 to Int64.
'       Unable to convert -1.79769313486232E+308 to UInt64.
'       Unable to convert -1.79769313486232E+308 to Decimal.
'       -1.79769313486232E+308 (Double) --> -Infinity (Single)
'
'       -67890.1234 (Double) --> -67890 (0xFFFFFFFFFFFEF6CE) (Int64)
'       Unable to convert -67890.1234 to UInt64.
'       -67890.1234 (Double) --> -67890.1234 (Decimal)
'       -67890.1234 (Double) --> -67890.13 (Single)
'
'       -12345.6789 (Double) --> -12346 (0xFFFFFFFFFFFFCFC6) (Int64)
'       Unable to convert -12345.6789 to UInt64.
'       -12345.6789 (Double) --> -12345.6789 (Decimal)
'       -12345.6789 (Double) --> -12345.68 (Single)
'
'       12345.6789 (Double) --> 12346 (0x000000000000303A) (Int64)
'       12345.6789 (Double) --> 12346 (0x000000000000303A) (UInt64)
'       12345.6789 (Double) --> 12345.6789 (Decimal)
'       12345.6789 (Double) --> 12345.68 (Single)
'
'       67890.1234 (Double) --> 67890 (0x0000000000010932) (Int64)
'       67890.1234 (Double) --> 67890 (0x0000000000010932) (UInt64)
'       67890.1234 (Double) --> 67890.1234 (Decimal)
'       67890.1234 (Double) --> 67890.13 (Single)
'
'       Unable to convert 1.79769313486232E+308 to Int64.
'       Unable to convert 1.79769313486232E+308 to UInt64.
'       Unable to convert 1.79769313486232E+308 to Decimal.
'       1.79769313486232E+308 (Double) --> Infinity (Single)
'
'       Unable to convert NaN to Int64.
'       Unable to convert NaN to UInt64.
'       Unable to convert NaN to Decimal.
'       NaN (Double) --> NaN (Single)
'
'       Unable to convert Infinity to Int64.
'       Unable to convert Infinity to UInt64.
'       Unable to convert Infinity to Decimal.
'       Infinity (Double) --> Infinity (Single)
'
'       Unable to convert -Infinity to Int64.
'       Unable to convert -Infinity to UInt64.
'       Unable to convert -Infinity to Decimal.
'       -Infinity (Double) --> -Infinity (Single)
' The example displays the following output for conversions performed
' in an unchecked context:
'       -1.79769313486232E+308 (Double) --> -9223372036854775808 (0x8000000000000000) (Int64)
'       -1.79769313486232E+308 (Double) --> 9223372036854775808 (0x8000000000000000) (UInt64)
'       Unable to convert -1.79769313486232E+308 to Decimal.
'       -1.79769313486232E+308 (Double) --> -Infinity (Single)
'
'       -67890.1234 (Double) --> -67890 (0xFFFFFFFFFFFEF6CE) (Int64)
'       -67890.1234 (Double) --> 18446744073709483726 (0xFFFFFFFFFFFEF6CE) (UInt64)
'       -67890.1234 (Double) --> -67890.1234 (Decimal)
'       -67890.1234 (Double) --> -67890.13 (Single)
'
'       -12345.6789 (Double) --> -12346 (0xFFFFFFFFFFFFCFC6) (Int64)
'       -12345.6789 (Double) --> 18446744073709539270 (0xFFFFFFFFFFFFCFC6) (UInt64)
'       -12345.6789 (Double) --> -12345.6789 (Decimal)
'       -12345.6789 (Double) --> -12345.68 (Single)
'
'       12345.6789 (Double) --> 12346 (0x000000000000303A) (Int64)
'       12345.6789 (Double) --> 12346 (0x000000000000303A) (UInt64)
'       12345.6789 (Double) --> 12345.6789 (Decimal)
'       12345.6789 (Double) --> 12345.68 (Single)
'
'       67890.1234 (Double) --> 67890 (0x0000000000010932) (Int64)
'       67890.1234 (Double) --> 67890 (0x0000000000010932) (UInt64)
'       67890.1234 (Double) --> 67890.1234 (Decimal)
'       67890.1234 (Double) --> 67890.13 (Single)
'
'       1.79769313486232E+308 (Double) --> -9223372036854775808 (0x8000000000000000) (Int64)
'       1.79769313486232E+308 (Double) --> 0 (0x0000000000000000) (UInt64)
'       Unable to convert 1.79769313486232E+308 to Decimal.
'       1.79769313486232E+308 (Double) --> Infinity (Single)
'
'       NaN (Double) --> -9223372036854775808 (0x8000000000000000) (Int64)
'       NaN (Double) --> 0 (0x0000000000000000) (UInt64)
'       Unable to convert NaN to Decimal.
'       NaN (Double) --> NaN (Single)
'
'       Infinity (Double) --> -9223372036854775808 (0x8000000000000000) (Int64)
'       Infinity (Double) --> 0 (0x0000000000000000) (UInt64)
'       Unable to convert Infinity to Decimal.
'       Infinity (Double) --> Infinity (Single)
'
'       -Infinity (Double) --> -9223372036854775808 (0x8000000000000000) (Int64)
'       -Infinity (Double) --> 9223372036854775808 (0x8000000000000000) (UInt64)
'       Unable to convert -Infinity to Decimal.
'       -Infinity (Double) --> -Infinity (Single)

숫자 형식의 변환에 대한 자세한 내용은 .NET 형식 변환 및 형식 변환 테이블참조하세요.

부동 소수점 기능

구조체 및 관련 형식은 Double 다음 영역에서 작업을 수행하는 메서드를 제공합니다.

  • 값의 비교입니다. Equals 메서드를 호출하여 두 Double 값이 같은지 또는 CompareTo 메서드를 호출하여 두 값 간의 관계를 확인할 수 있습니다.

    Double 구조체는 전체 비교 연산자 집합도 지원합니다. 예를 들어 같음 또는 같지 않음을 테스트하거나 한 값이 다른 값보다 크거나 같은지 확인할 수 있습니다. 피연산자 중 하나가 숫자 형식이 아닌 Double인 경우, 비교를 수행하기 전에 Double로 변환됩니다.

    Warning

    정밀도의 차이로 인해 같을 것으로 예상되는 두 Double 값이 같지 않은 것으로 판명되어 비교 결과에 영향을 줄 수 있습니다. 두 Double 값을 비교하는 방법에 대한 자세한 내용은 ‘동일성 테스트’ 섹션을 참조하세요.

    IsNaN, IsInfinity, IsPositiveInfinityIsNegativeInfinity 메서드를 호출하여 이러한 특수 값을 테스트할 수도 있습니다.

  • 수학 연산. 더하기, 빼기, 곱하기 및 나누기와 같은 일반적인 산술 연산은 메서드가 아닌 언어 컴파일러 및 CIL(공용 중간 언어) 명령에 의해 Double 구현됩니다. 수학 연산의 피연산자 중 하나가 Double가 아닌 다른 숫자 형식인 경우, 연산을 수행하기 전에 Double로 변환됩니다. 작업의 결과도 Double 값입니다.

    다른 수학 연산은 static 클래스에서 Shared(Visual Basic System.Math) 메서드를 호출하여 수행할 수 있습니다. 여기에는 산술(예: Math.Abs, Math.SignMath.Sqrt), 기하(예: Math.CosMath.Sin), 그리고 미적분(예: Math.Log)에 일반적으로 사용되는 추가적인 메서드가 포함됩니다.

    Double 값의 개별 비트를 조작할 수도 있습니다. 이 메서드는 BitConverter.DoubleToInt64Bits 값의 비트 패턴을 64비트 정수로 유지합니다 Double . BitConverter.GetBytes(Double) 메서드는 바이트 배열에서 비트 패턴을 반환합니다.

  • 반올림. 반올림은 부동 소수점 표현과 정밀도 문제로 인해 발생하는 값 간의 차이를 줄이는 기술로 자주 사용됩니다. Double 메서드를 호출하여 Math.Round 값을 반올림할 수 있습니다.

  • 서식. 값을 문자열로 변환하려면 Double 메서드를 호출하거나 복합 서식 지정 기능을 사용하세요. 서식 문자열이 부동 소수점 값의 문자열 표현을 제어하는 방법에 대한 자세한 내용은 표준 숫자 형식 문자열사용자 지정 숫자 형식 문자열을 참조하세요.

  • 문자열구문 분석. 당신은 Double 또는 Parse 메서드를 호출하여 부동 소수점 값의 문자열 표현을 TryParse 값으로 변환할 수 있습니다. 구문 분석 작업이 실패하면 Parse 메서드는 예외를 throw하는 반면 TryParse 메서드는 false반환합니다.

  • 형식 변환. Double 구조는 두 표준 .NET 데이터 형식 간의 변환을 지원하는 IConvertible 인터페이스에 대한 명시적 인터페이스 구현을 제공합니다. 언어 컴파일러에서는 다른 모든 표준 숫자 형식의 값을 Double 값으로 암시적으로 변환하는 것도 지원합니다. 표준 숫자 형식의 값을 a Double 로 변환하는 것은 확대 변환이며 캐스팅 연산자 또는 변환 메서드의 사용자가 필요하지 않습니다.

    그러나 Int64Single 값의 변환에는 정밀도 손실이 발생할 수 있습니다. 다음 표에서는 이러한 각 형식의 정밀도 차이를 보여줍니다.

    유형 최대 정밀도 내부 정밀도
    Double 15 17
    Int64 19자리 십진수 19자리 십진수
    Single 10진수 7자리 10진수 9자리

    정밀도 문제는 Single 값으로 변환되는 Double 값에 가장 자주 영향을 줍니다. 다음 예제에서는 값 중 하나가 단정밀도 부동 소수점 값 Double이므로 동일한 나누기 연산에서 생성된 두 값은 같지 않습니다.

    using System;
    
    public class Example13
    {
        public static void Main()
        {
            Double value = .1;
            Double result1 = value * 10;
            Double result2 = 0;
            for (int ctr = 1; ctr <= 10; ctr++)
                result2 += value;
    
            Console.WriteLine($".1 * 10:           {result1:R}");
            Console.WriteLine($".1 Added 10 times: {result2:R}");
        }
    }
    // The example displays the following output:
    //       .1 * 10:           1
    //       .1 Added 10 times: 0.99999999999999989
    
    let value = 0.1
    let result1 = value * 10.
    let mutable result2 = 0.
    for i = 1 to 10 do
        result2 <- result2 + value
    
    printfn $".1 * 10:           {result1:R}"
    printfn $".1 Added 10 times: {result2:R}"
    // The example displays the following output:
    //       .1 * 10:           1
    //       .1 Added 10 times: 0.99999999999999989
    
    Module Example14
        Public Sub Run()
            Dim value As Double = 0.1
            Dim result1 As Double = value * 10
            Dim result2 As Double
            For ctr As Integer = 1 To 10
                result2 += value
            Next
            Console.WriteLine(".1 * 10:           {0:R}", result1)
            Console.WriteLine(".1 Added 10 times: {0:R}", result2)
        End Sub
    End Module
    ' The example displays the following output:
    '       .1 * 10:           1
    '       .1 Added 10 times: 0.99999999999999989
    

필드

Name Description
E

상수(e)로 지정된 자연 로그 밑을 나타냅니다.

Epsilon

0보다 큰 가장 작은 양수 Double 값을 나타냅니다. 이 필드는 상수입니다.

MaxValue

의 가능한 가장 큰 값을 나타냅니다 Double. 이 필드는 상수입니다.

MinValue

가능한 가장 작은 값을 Double나타냅니다. 이 필드는 상수입니다.

NaN

숫자(NaN)가 아닌 값을 나타냅니다. 이 필드는 상수입니다.

NegativeInfinity

음의 무한대를 나타냅니다. 이 필드는 상수입니다.

NegativeZero

음수 0(-0)을 나타냅니다.

Pi

원과 지름의 둘레 비율을 나타내며 상수 π 지정합니다.

PositiveInfinity

양의 무한대를 나타냅니다. 이 필드는 상수입니다.

Tau

상수로 지정된 한 턴의 라디안 수를 나타냅니다.

메서드

Name Description
Abs(Double)

값의 절대값을 계산합니다.

Acos(Double)

값의 아크 코사인을 계산합니다.

Acosh(Double)

값의 하이퍼볼릭 아크 코사인을 계산합니다.

AcosPi(Double)

값의 아크 코사인을 계산하고 결과를 pi으로 나눕니다.

Asin(Double)

값의 아크 사인을 계산합니다.

Asinh(Double)

값의 하이퍼볼릭 아크 사인을 계산합니다.

AsinPi(Double)

값의 아크 사인을 계산하고 결과를 pi.로 나눕니다.

Atan(Double)

값의 아크 탄젠트를 계산합니다.

Atan2(Double, Double)

두 값의 몫의 아크 탄젠트를 계산합니다.

Atan2Pi(Double, Double)

두 값의 몫에 대한 아크 탄젠트를 계산하고 결과를 으로 pi나눕니다.

Atanh(Double)

값의 하이퍼볼릭 아크 탄젠트를 계산합니다.

AtanPi(Double)

값의 아크 탄젠트를 계산하고 결과를 pi로 나눕니다.

BitDecrement(Double)

지정된 값보다 작은 값을 비교하는 가장 큰 값을 반환합니다.

BitIncrement(Double)

지정된 값보다 큰 값을 비교하는 가장 작은 값을 반환합니다.

Cbrt(Double)

값의 큐브 루트를 계산합니다.

Ceiling(Double)

값의 최대값을 계산합니다.

Clamp(Double, Double, Double)

값을 포괄 최소값 및 최대값으로 고정합니다.

ClampNative(Double, Double, Double)

플랫폼별 동작 NaN 을 사용하여 값을 포괄 최소값 및 최대값으로 고정합니다 NegativeZero.

CompareTo(Double)

이 인스턴스를 지정된 배정밀도 부동 소수점 숫자와 비교하고 이 인스턴스의 값이 지정된 배정밀도 부동 소수점 숫자의 값보다 작거나 같은지 또는 더 큰지를 나타내는 정수를 반환합니다.

CompareTo(Object)

이 인스턴스를 지정된 개체와 비교하고 이 인스턴스의 값이 지정된 개체의 값보다 작거나 같은지 또는 더 큰지를 나타내는 정수를 반환합니다.

ConvertToInteger<TInteger>(Double)

오버플로 시 채도를 사용하여 값을 지정된 정수 형식으로 변환합니다.

ConvertToIntegerNative<TInteger>(Double)

오버플로 시 플랫폼별 동작을 사용하여 값을 지정된 정수 형식으로 변환합니다.

CopySign(Double, Double)

값의 기호를 다른 값의 기호에 복사합니다.

Cos(Double)

값의 코사인을 계산합니다.

Cosh(Double)

값의 하이퍼볼릭 코사인을 계산합니다.

CosPi(Double)

에 의해 pi배수된 값의 코사인을 계산합니다.

CreateChecked<TOther>(TOther)

현재 형식의 표현 가능한 범위를 벗어나는 값에 대해 오버플로 예외를 throw하여 값에서 현재 형식의 인스턴스를 만듭니다.

CreateSaturating<TOther>(TOther)

현재 형식의 표현 가능한 범위를 벗어나는 모든 값을 채도하여 값에서 현재 형식의 인스턴스를 만듭니다.

CreateTruncating<TOther>(TOther)

현재 형식의 표현 가능한 범위를 벗어나는 값을 잘라내어 값에서 현재 형식의 인스턴스를 만듭니다.

DegreesToRadians(Double)

지정된 값을 도에서 라디안으로 변환합니다.

Equals(Double)

이 인스턴스와 지정된 Double 개체가 동일한 값을 나타내는지 여부를 나타내는 값을 반환합니다.

Equals(Object)

이 인스턴스가 지정된 개체와 같은지 여부를 나타내는 값을 반환합니다.

Exp(Double)

E 지정된 전력으로 발생하는 컴퓨팅입니다.

Exp10(Double)

10 지정된 전력으로 발생하는 컴퓨팅입니다.

Exp10M1(Double)

10 지정된 전원으로 발생된 계산을 수행하고 1을 뺍니다.

Exp2(Double)

2 지정된 전력으로 발생하는 컴퓨팅입니다.

Exp2M1(Double)

2 지정된 전원으로 발생된 계산을 수행하고 1을 뺍니다.

ExpM1(Double)

E 지정된 전원으로 발생된 계산을 수행하고 1을 뺍니다.

Floor(Double)

값의 바닥을 계산합니다.

FusedMultiplyAdd(Double, Double, Double)

3개 값의 융합 곱하기-추가를 계산합니다.

GetHashCode()

이 인스턴스의 해시 코드를 반환합니다.

GetTypeCode()

for 값 형식을 TypeCode 반환합니다 Double.

Hypot(Double, Double)

오른쪽 각도 삼각형에서 더 짧은 면의 길이를 나타내는 두 값이 지정된 경우 가설을 계산합니다.

Ieee754Remainder(Double, Double)

IEEE 754에서 지정한 대로 두 값의 나머지를 계산합니다.

ILogB(Double)

값의 정수 로그를 계산합니다.

IsEvenInteger(Double)

값이 짝수 정수인지 여부를 확인합니다.

IsFinite(Double)

지정된 값이 유한(0, 하위 또는 보통)인지 여부를 확인합니다.

IsInfinity(Double)

지정된 숫자가 음수 또는 양수 무한대로 계산되는지 여부를 나타내는 값을 반환합니다.

IsInteger(Double)

값이 정수 값을 나타내는지 여부를 결정합니다.

IsNaN(Double)

지정된 값이 숫자(NaN)가 아닌지 여부를 나타내는 값을 반환합니다.

IsNegative(Double)

지정된 값이 음수인지 여부를 확인합니다.

IsNegativeInfinity(Double)

지정된 숫자가 음수 무한대로 계산되는지 여부를 나타내는 값을 반환합니다.

IsNormal(Double)

지정된 값이 정상인지 여부를 확인합니다.

IsOddInteger(Double)

값이 홀수 정수인지 여부를 결정합니다.

IsPositive(Double)

값이 양수인지 여부를 확인합니다.

IsPositiveInfinity(Double)

지정된 숫자가 양의 무한대로 평가되는지 여부를 나타내는 값을 반환합니다.

IsPow2(Double)

값이 2의 힘인지 확인합니다.

IsRealNumber(Double)

값이 실수인지 여부를 확인합니다.

IsSubnormal(Double)

지정된 값이 하위 값인지 여부를 확인합니다.

Lerp(Double, Double, Double)

지정된 가중치에 따라 두 값 사이의 선형 보간을 수행합니다.

Log(Double, Double)

지정된 베이스에 있는 값의 로그를 계산합니다.

Log(Double)

값의 자연(base-E 로그)을 계산합니다.

Log10(Double)

값의 base-10 로그를 계산합니다.

Log10P1(Double)

값의 base-10 로그와 1을 계산합니다.

Log2(Double)

값의 log2를 계산합니다.

Log2P1(Double)

값의 base-2 로그와 1을 계산합니다.

LogP1(Double)

값에 1을 더한 자연base-E 로그를 계산합니다.

Max(Double, Double)

두 값을 더 큰 컴퓨팅과 비교합니다.

MaxMagnitude(Double, Double)

두 값을 더 큰 컴퓨팅과 비교합니다.

MaxMagnitudeNumber(Double, Double)

크기가 더 큰 컴퓨팅과 두 값을 비교하고 입력 NaN이 있는 경우 다른 값을 반환합니다.

MaxNative(Double, Double)

플랫폼별 동작 NaN 을 사용하여 더 큰 컴퓨팅과 두 값을 비교합니다 NegativeZero.

MaxNumber(Double, Double)

두 값을 더 큰 컴퓨팅과 비교하고 입력 NaN이 있는 경우 다른 값을 반환합니다.

Min(Double, Double)

두 값을 더 작은 컴퓨팅과 비교합니다.

MinMagnitude(Double, Double)

두 값을 더 작은 컴퓨팅과 비교합니다.

MinMagnitudeNumber(Double, Double)

크기가 작은 컴퓨팅과 두 값을 비교하고 입력 NaN이 있으면 다른 값을 반환합니다.

MinNative(Double, Double)

플랫폼별 동작 NaN 을 사용하는 컴퓨팅과 두 값을 비교합니다 NegativeZero.

MinNumber(Double, Double)

두 값을 더 작은 컴퓨팅과 비교하고 입력 NaN이 있으면 다른 값을 반환합니다.

MultiplyAddEstimate(Double, Double, Double)

() + left.의 추정치를 * rightaddend 계산합니다.

Parse(ReadOnlySpan<Byte>, IFormatProvider)

UTF-8 문자의 범위를 값으로 구문 분석합니다.

Parse(ReadOnlySpan<Byte>, NumberStyles, IFormatProvider)

UTF-8 문자의 범위를 값으로 구문 분석합니다.

Parse(ReadOnlySpan<Char>, IFormatProvider)

문자 범위를 값으로 구문 분석합니다.

Parse(ReadOnlySpan<Char>, NumberStyles, IFormatProvider)

지정된 스타일 및 문화권별 형식의 숫자 문자열 표현이 포함된 문자 범위를 해당하는 배정밀도 부동 소수점 숫자로 변환합니다.

Parse(String, IFormatProvider)

지정된 문화권별 형식의 숫자 문자열 표현을 해당하는 배정밀도 부동 소수점 숫자로 변환합니다.

Parse(String, NumberStyles, IFormatProvider)

지정된 스타일 및 문화권별 형식의 숫자 문자열 표현을 해당하는 배정밀도 부동 소수점 숫자로 변환합니다.

Parse(String, NumberStyles)

지정된 스타일의 숫자 문자열 표현을 해당하는 배정밀도 부동 소수점 숫자로 변환합니다.

Parse(String)

숫자의 문자열 표현을 해당하는 배정밀도 부동 소수점 숫자로 변환합니다.

Pow(Double, Double)

지정된 전력으로 발생한 값을 계산합니다.

RadiansToDegrees(Double)

지정된 값을 라디안에서 도로 변환합니다.

ReciprocalEstimate(Double)

값의 역수 추정값을 계산합니다.

ReciprocalSqrtEstimate(Double)

값의 역 제곱근 추정값을 계산합니다.

RootN(Double, Int32)

값의 n번째 루트를 계산합니다.

Round(Double, Int32, MidpointRounding)

기본 반올림 모드(ToEven)를 사용하여 값을 지정된 소수 자릿수로 반올림합니다.

Round(Double, Int32)

기본 반올림 모드(ToEven)를 사용하여 값을 지정된 소수 자릿수로 반올림합니다.

Round(Double, MidpointRounding)

지정된 반올림 모드를 사용하여 값을 가장 가까운 정수로 반올림합니다.

Round(Double)

기본 반올림 모드(ToEven)를 사용하여 값을 가장 가까운 정수로 반올림합니다.

ScaleB(Double, Int32)

값의 곱과 지정된 전력으로 발생된 기본 반지름을 계산합니다.

Sign(Double)

값의 부호를 계산합니다.

Sin(Double)

값의 사인을 계산합니다.

SinCos(Double)

값의 사인과 코사인을 계산합니다.

SinCosPi(Double)

값의 사인과 코사인을 계산합니다.

Sinh(Double)

값의 하이퍼볼릭 사인을 계산합니다.

SinPi(Double)

을 곱한 값의 사인을 pi계산합니다.

Sqrt(Double)

값의 제곱근을 계산합니다.

Tan(Double)

값의 탄젠트를 계산합니다.

Tanh(Double)

값의 하이퍼볼릭 탄젠트를 계산합니다.

TanPi(Double)

에 의해 pi배수된 값의 탄젠트를 계산합니다.

ToString()

이 인스턴스의 숫자 값을 해당하는 문자열 표현으로 변환합니다.

ToString(IFormatProvider)

지정된 문화권별 형식 정보를 사용하여 이 인스턴스의 숫자 값을 해당하는 문자열 표현으로 변환합니다.

ToString(String, IFormatProvider)

지정된 형식 및 문화권별 형식 정보를 사용하여 이 인스턴스의 숫자 값을 해당하는 문자열 표현으로 변환합니다.

ToString(String)

지정된 형식을 사용하여 이 인스턴스의 숫자 값을 해당하는 문자열 표현으로 변환합니다.

Truncate(Double)

값을 자립니다.

TryFormat(Span<Byte>, Int32, ReadOnlySpan<Char>, IFormatProvider)

현재 인스턴스의 값을 제공된 바이트 범위로 UTF-8로 서식을 지정하려고 시도합니다.

TryFormat(Span<Char>, Int32, ReadOnlySpan<Char>, IFormatProvider)

현재 이중 인스턴스의 값을 제공된 문자 범위로 서식을 지정하려고 시도합니다.

TryParse(ReadOnlySpan<Byte>, Double)

숫자의 문자열 표현을 포함하는 UTF-8 문자 범위를 해당하는 배정밀도 부동 소수점 숫자로 변환하려고 시도합니다.

TryParse(ReadOnlySpan<Byte>, IFormatProvider, Double)

UTF-8 문자의 범위를 값으로 구문 분석하려고 시도합니다.

TryParse(ReadOnlySpan<Byte>, NumberStyles, IFormatProvider, Double)

UTF-8 문자의 범위를 값으로 구문 분석하려고 시도합니다.

TryParse(ReadOnlySpan<Char>, Double)

지정된 스타일 및 문화권별 형식의 숫자 범위 표현을 해당하는 배정밀도 부동 소수점 숫자로 변환합니다. 반환 값은 변환이 성공했는지 아니면 실패했는지를 나타냅니다.

TryParse(ReadOnlySpan<Char>, IFormatProvider, Double)

문자 범위를 값으로 구문 분석하려고 시도합니다.

TryParse(ReadOnlySpan<Char>, NumberStyles, IFormatProvider, Double)

지정된 스타일 및 문화권별 형식의 숫자 문자열 표현이 포함된 문자 범위를 해당하는 배정밀도 부동 소수점 숫자로 변환합니다. 반환 값은 변환이 성공했는지 아니면 실패했는지를 나타냅니다.

TryParse(String, Double)

숫자의 문자열 표현을 해당하는 배정밀도 부동 소수점 숫자로 변환합니다. 반환 값은 변환이 성공했는지 아니면 실패했는지를 나타냅니다.

TryParse(String, IFormatProvider, Double)

문자열을 값으로 구문 분석하려고 시도합니다.

TryParse(String, NumberStyles, IFormatProvider, Double)

지정된 스타일 및 문화권별 형식의 숫자 문자열 표현을 해당하는 배정밀도 부동 소수점 숫자로 변환합니다. 반환 값은 변환이 성공했는지 아니면 실패했는지를 나타냅니다.

연산자

Name Description
Equality(Double, Double)

지정된 Double 두 값이 같은지 여부를 나타내는 값을 반환합니다.

GreaterThan(Double, Double)

지정된 값이 지정된 Double 다른 Double 값보다 큰지 여부를 나타내는 값을 반환합니다.

GreaterThanOrEqual(Double, Double)

지정된 값이 지정된 Double 다른 Double 값보다 크거나 같은지 여부를 나타내는 값을 반환합니다.

Inequality(Double, Double)

지정된 Double 두 값이 같지 않은지 여부를 나타내는 값을 반환합니다.

LessThan(Double, Double)

지정된 값이 지정된 Double 다른 Double 값보다 작은지 여부를 나타내는 값을 반환합니다.

LessThanOrEqual(Double, Double)

지정된 값이 지정된 Double 다른 Double 값보다 작거나 같은지 여부를 나타내는 값을 반환합니다.

명시적 인터페이스 구현

Name Description
IAdditionOperators<Double,Double,Double>.Addition(Double, Double)

합계를 계산하기 위해 두 값을 함께 추가합니다.

IAdditiveIdentity<Double,Double>.AdditiveIdentity

현재 형식의 추가 ID를 가져옵니다.

IBinaryNumber<Double>.AllBitsSet

모든 비트가 설정된 이진 형식의 인스턴스를 가져옵니다.

IBitwiseOperators<Double,Double,Double>.BitwiseAnd(Double, Double)

두 값의 비트 및 값을 계산합니다.

IBitwiseOperators<Double,Double,Double>.BitwiseOr(Double, Double)

비트 또는 두 값을 계산합니다.

IBitwiseOperators<Double,Double,Double>.ExclusiveOr(Double, Double)

배타적 또는 두 값을 계산합니다.

IBitwiseOperators<Double,Double,Double>.OnesComplement(Double)

지정된 값의 보수 표현을 계산합니다.

IComparable.CompareTo(Object)

현재 인스턴스를 동일한 형식의 다른 개체와 비교하고 현재 인스턴스가 다른 개체와 정렬 순서의 동일한 위치에서 선행, 팔로우 또는 발생하는지 여부를 나타내는 정수를 반환합니다.

IConvertible.GetTypeCode()

이 인스턴스에 TypeCode 대한 값을 반환합니다.

IConvertible.ToBoolean(IFormatProvider)

이 멤버에 대한 설명은 을 참조하세요 ToBoolean(IFormatProvider).

IConvertible.ToByte(IFormatProvider)

이 멤버에 대한 설명은 을 참조하세요 ToByte(IFormatProvider).

IConvertible.ToChar(IFormatProvider)

이 변환은 지원되지 않습니다. 이 메서드를 사용하려고 하면 .InvalidCastException

IConvertible.ToDateTime(IFormatProvider)

이 변환은 지원되지 않습니다. 이 메서드를 사용하려고 하면 .InvalidCastException

IConvertible.ToDecimal(IFormatProvider)

이 멤버에 대한 설명은 을 참조하세요 ToDecimal(IFormatProvider).

IConvertible.ToDouble(IFormatProvider)

이 멤버에 대한 설명은 을 참조하세요 ToDouble(IFormatProvider).

IConvertible.ToInt16(IFormatProvider)

이 멤버에 대한 설명은 을 참조하세요 ToInt16(IFormatProvider).

IConvertible.ToInt32(IFormatProvider)

이 멤버에 대한 설명은 을 참조하세요 ToInt32(IFormatProvider).

IConvertible.ToInt64(IFormatProvider)

이 멤버에 대한 설명은 을 참조하세요 ToInt64(IFormatProvider).

IConvertible.ToSByte(IFormatProvider)

이 멤버에 대한 설명은 을 참조하세요 ToSByte(IFormatProvider).

IConvertible.ToSingle(IFormatProvider)

이 멤버에 대한 설명은 을 참조하세요 ToSingle(IFormatProvider).

IConvertible.ToType(Type, IFormatProvider)

이 멤버에 대한 설명은 을 참조하세요 ToType(Type, IFormatProvider).

IConvertible.ToUInt16(IFormatProvider)

이 멤버에 대한 설명은 을 참조하세요 ToUInt16(IFormatProvider).

IConvertible.ToUInt32(IFormatProvider)

이 멤버에 대한 설명은 을 참조하세요 ToUInt32(IFormatProvider).

IConvertible.ToUInt64(IFormatProvider)

이 멤버에 대한 설명은 을 참조하세요 ToUInt64(IFormatProvider).

IDecrementOperators<Double>.Decrement(Double)

값을 줄입니다.

IDivisionOperators<Double,Double,Double>.Division(Double, Double)

한 값을 다른 값으로 나누어 몫을 계산합니다.

IFloatingPoint<Double>.GetExponentByteCount()

의 일부로 TryWriteExponentLittleEndian(Span<Byte>, Int32)기록될 바이트 수를 가져옵니다.

IFloatingPoint<Double>.GetExponentShortestBitLength()

현재 지수에 대한 가장 짧은 두 개의 보수 표현의 길이(비트)를 가져옵니다.

IFloatingPoint<Double>.GetSignificandBitLength()

현재 significand의 길이를 비트 단위로 가져옵니다.

IFloatingPoint<Double>.GetSignificandByteCount()

의 일부로 TryWriteSignificandLittleEndian(Span<Byte>, Int32)기록될 바이트 수를 가져옵니다.

IFloatingPoint<Double>.TryWriteExponentBigEndian(Span<Byte>, Int32)

현재 지수를 big-endian 형식으로 지정된 범위에 쓰려고 시도합니다.

IFloatingPoint<Double>.TryWriteExponentLittleEndian(Span<Byte>, Int32)

현재 지수(little-endian 형식)를 지정된 범위에 쓰려고 합니다.

IFloatingPoint<Double>.TryWriteSignificandBigEndian(Span<Byte>, Int32)

현재 중요를 big-endian 형식으로 지정된 범위에 쓰려고 시도합니다.

IFloatingPoint<Double>.TryWriteSignificandLittleEndian(Span<Byte>, Int32)

현재 유의한 값을 little-endian 형식으로 지정된 범위에 쓰려고 시도합니다.

IFloatingPointConstants<Double>.E

수학 상수 e입니다.

IFloatingPointConstants<Double>.Pi

수학 상수 pi입니다.

IFloatingPointConstants<Double>.Tau

수학 상수 tau입니다.

IFloatingPointIeee754<Double>.Epsilon

에 추가할 00수 있는 가장 작은 값을 가져옵니다.

IFloatingPointIeee754<Double>.NaN

를 나타내는 값을 가져옵니다 NaN.

IFloatingPointIeee754<Double>.NegativeInfinity

infinity수인 값을 가져옵니다.

IFloatingPointIeee754<Double>.NegativeZero

zero수인 값을 가져옵니다.

IFloatingPointIeee754<Double>.PositiveInfinity

양의 infinity값을 가져옵니다.

IIncrementOperators<Double>.Increment(Double)

값을 증분합니다.

IMinMaxValue<Double>.MaxValue

현재 형식의 최대값을 가져옵니다.

IMinMaxValue<Double>.MinValue

현재 형식의 최소값을 가져옵니다.

IModulusOperators<Double,Double,Double>.Modulus(Double, Double)

두 값을 함께 나누어 모듈러스 또는 나머지를 계산합니다.

IMultiplicativeIdentity<Double,Double>.MultiplicativeIdentity

현재 형식의 곱하기 ID를 가져옵니다.

IMultiplyOperators<Double,Double,Double>.Multiply(Double, Double)

두 값을 함께 곱하여 제품을 계산합니다.

INumberBase<Double>.IsCanonical(Double)

값이 정식 표현에 있는지 여부를 확인합니다.

INumberBase<Double>.IsComplexNumber(Double)

값이 복소수를 나타내는지 여부를 결정합니다.

INumberBase<Double>.IsImaginaryNumber(Double)

값이 순수 허수 수를 나타내는지 여부를 확인합니다.

INumberBase<Double>.IsZero(Double)

값이 0인지 여부를 확인합니다.

INumberBase<Double>.One

형식의 값을 1 가져옵니다.

INumberBase<Double>.Radix

형식의 radix 또는 base를 가져옵니다.

INumberBase<Double>.TryConvertFromChecked<TOther>(TOther, Double)

배정밀도 부동 소수점 숫자를 나타냅니다.

INumberBase<Double>.TryConvertFromSaturating<TOther>(TOther, Double)

배정밀도 부동 소수점 숫자를 나타냅니다.

INumberBase<Double>.TryConvertFromTruncating<TOther>(TOther, Double)

배정밀도 부동 소수점 숫자를 나타냅니다.

INumberBase<Double>.TryConvertToChecked<TOther>(Double, TOther)

현재 형식의 인스턴스를 다른 형식으로 변환하여 현재 형식의 표시 가능한 범위를 벗어나는 값에 대해 오버플로 예외를 throw합니다.

INumberBase<Double>.TryConvertToSaturating<TOther>(Double, TOther)

현재 형식의 인스턴스를 다른 형식으로 변환하여 현재 형식의 표현 가능한 범위를 벗어나는 값을 채도합니다.

INumberBase<Double>.TryConvertToTruncating<TOther>(Double, TOther)

현재 형식의 인스턴스를 다른 형식으로 변환하여 현재 형식의 표현 가능한 범위를 벗어나는 값을 잘리려고 합니다.

INumberBase<Double>.Zero

형식의 값을 0 가져옵니다.

ISignedNumber<Double>.NegativeOne

형식의 값을 -1 가져옵니다.

ISubtractionOperators<Double,Double,Double>.Subtraction(Double, Double)

두 값을 빼서 차이를 계산합니다.

IUnaryNegationOperators<Double,Double>.UnaryNegation(Double)

값의 단항 부정을 계산합니다.

IUnaryPlusOperators<Double,Double>.UnaryPlus(Double)

값의 단항 플러스를 계산합니다.

적용 대상

스레드 보안

이 형식의 모든 멤버는 스레드로부터 안전합니다. 인스턴스 상태를 수정하는 것처럼 보이는 멤버는 실제로 새 값으로 초기화된 새 인스턴스를 반환합니다. 다른 형식과 마찬가지로 이 형식의 인스턴스를 포함하는 공유 변수에 대한 읽기 및 쓰기는 스레드 안전을 보장하기 위해 잠금으로 보호되어야 합니다.

추가 정보