C#의 Decimal.ToSingle() 메서드는 지정된 Decimal의 값을 동등한 단정밀도 부동 소수점 숫자로 변환하는 데 사용됩니다.
구문
다음은 구문입니다 -
public static float ToSingle (decimal val);
위의 Val은 변환할 십진수입니다.
예
이제 Decimal.ToSingle() 메서드를 구현하는 예를 살펴보겠습니다. -
using System;
public class Demo {
public static void Main(){
Decimal val = 0.00000007575833m;
Console.WriteLine("Decimal value = "+val);
float res = Decimal.ToSingle(val);
Console.WriteLine("Single-precision floating-point number = "+res);
}
} 출력
이것은 다음과 같은 출력을 생성합니다 -
Decimal value = 0.00000007575833 Single-precision floating-point number = 7.575833E-08
예
이제 Decimal.ToSingle() 메서드를 구현하는 또 다른 예를 살펴보겠습니다. -
using System;
public class Demo {
public static void Main(){
Decimal val = 8767576576m;
Console.WriteLine("Decimal value = "+val);
float res = Decimal.ToSingle(val);
Console.WriteLine("Single-precision floating-point number = "+res);
}
} 출력
이것은 다음과 같은 출력을 생성합니다 -
Decimal value = 8767576576 Single-precision floating-point number = 8.767576E+09