C#
Decimal 형식의 이해
JAESEONG LEE- developer
2022. 7. 15. 16:47
Decimal 도 실수를 다루는 데이터 형식입니다. 29자리 데이터를 표현할 수 있는 소수 형식입니다.
float, double 와 비교해서 얼마나 정밀한지 시험해보는 프로그램입니다.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
using System;
namespace Decimal
{
class MainApp
{
static void Main(string[] args)
{
float a = 3.141592653589793238462643383279f;
double b = 3.141592653589793238462643383279;
decimal c = 3.141592653589793238462643383279m;
Console.WriteLine(a);
Console.WriteLine(b);
Console.WriteLine(c);
}
}
}
|
cs |
Decimal 은 파이의 소수점이 한계까지 나타낼 수 있었습니다.