본문 바로가기
프로그래밍/C#

C#] 데이터 형식

by 곰나나 2024. 1. 10.

[데이터 형식]

1. 정수 데이터 형식

- 부호 있는(signed) : +,-부호가 있는 정수형. 양수와 음수

- 부호 없는(unsigned) : + 값만 다루는 정수형. 양수만

 

2. 부호 있는 정수 데이터 형식

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
using System;
using System.Collections.Generic;
 
internal class Integer_Deom
{
    static void Main()
    {
        //& 변수 선언
        sbyte MinSByt = sbyte.MinValue;
        sbyte MaxSByt = sbyte.MaxValue;
 
        short MinShort = short.MinValue;
        short MaxShort = short.MaxValue;
 
        int MinInt = int.MinValue;
        int MaxInt = int.MaxValue;
 
        long MinLong = long.MinValue;
        long MaxLong = long.MaxValue;
 
        //& 출력
        Console.WriteLine($"Min sbyte : {MinSByt}");
        Console.WriteLine($"Max sbyte : {MaxSByt}");
        Console.WriteLine("\n");
        Console.WriteLine($"Min short : {MinShort}");
        Console.WriteLine($"Min short : {MaxShort}");
        Console.WriteLine("\n");
        Console.WriteLine($"Min int : {MinInt}");
        Console.WriteLine($"Min int : {MaxInt}");
        Console.WriteLine("\n");
        Console.WriteLine($"Min long : {MinLong}");
        Console.WriteLine($"Min long : {MaxLong}");
    }// main
}// Integer_Deom
cs

3. 부호 없는 정수 데이터 형식

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
using System;
using System.Collections.Generic;
 
internal class Integer_Deom
{
    static void Main()
    {
        //& 변수 선언
        byte MinByte = byte.MinValue;
        byte MaxByte = byte.MaxValue;
 
        ushort MinUshort = ushort.MinValue;
        ushort MaxUshort = ushort.MaxValue;
 
        uint MinUint = uint.MinValue;
        uint MaxUint = uint.MaxValue;
 
        ulong MinUlong = ulong.MinValue;
        ulong MaxUlong = ulong.MaxValue;
 
        //& 출력
        Console.WriteLine($"Min byte : {MinByte}");
        Console.WriteLine($"Max byte : {MaxByte}");
        Console.WriteLine("\n");
        Console.WriteLine($"Min ushort : {MinUshort}");
        Console.WriteLine($"Max ushort : {MaxUshort}");
        Console.WriteLine("\n");
        Console.WriteLine($"Min uint : {MinUint}");
        Console.WriteLine($"Max uint : {MaxUint}");
        Console.WriteLine("\n");
        Console.WriteLine($"Min ulong : {MinUlong}");
        Console.WriteLine($"Max ulong : {MaxUlong}");
 
    }// main
}// Integer_Deom
cs

4. 실수 데이터 형식

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
using System;
using System.Collections.Generic;
 
internal class Integer_Deom
{
    static void Main()
    {
        //& 변수 선언
        float MinFloat = float.MinValue;
        float MaxFloat = float.MaxValue;
 
        double MinDouble = double.MinValue;
        double MaxDouble = double.MaxValue;
 
        decimal MinDecimal = decimal.MinValue;
        decimal MaxDecimal = decimal.MaxValue;
 
        //& 출력
        Console.WriteLine($"Min float : {MinFloat}");
        Console.WriteLine($"Max float : {MaxFloat}");
        Console.WriteLine("\n");
        Console.WriteLine($"Min double : {MinDouble}");
        Console.WriteLine($"Max double : {MaxDouble}");
        Console.WriteLine("\n");
        Console.WriteLine($"Min decimal : {MinDecimal}");
        Console.WriteLine($"Max decimal : {MaxDecimal}");
 
    }// main
}// Integer_Deom
cs

728x90

'프로그래밍 > C#' 카테고리의 다른 글

C#] 형식 변환  (0) 2024.01.10
C#] 입력문  (0) 2024.01.10
C#] 상수  (1) 2024.01.10
C#] 변수  (1) 2024.01.10
C#] 이스케이프 시퀀스  (0) 2023.12.31