본문 바로가기
C#

정수 형식 예제 프로그램

by JAESEONG LEE- developer 2022. 7. 15.

코드

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
using System;
 
namespace IntegralTypes
{
    class MainApp
    {
        static void Main(string[] args)
        {
            sbyte a = -10;
            byte b = 40;
 
            Console.WriteLine("a={0}, b={1}", a, b);
 
            short c = -30000;
            ushort d = 60000;
 
            Console.WriteLine("c={0}, d={1}", c, d);
 
            int e = -10000000// 0이 7개
            uint f = 300000000// 0이 8개
 
            Console.WriteLine("e={0}, f={1}", e, f);
 
            long g = -500000000000// 0이 11개
            ulong h = 2000000000000000000// 0이 18개
 
            Console.WriteLine("g={0}, h ={1}", g, h);
        }
    }
}
cs

 

이 코드를 컴파일하면 

 

이러한 실행 결과가 나오게 된다.

'C#' 카테고리의 다른 글

Overflow 의 이해  (0) 2022.07.15
2의 보수법을 이용한 음수 표현법  (0) 2022.07.15
정수 계열 형식  (0) 2022.07.15
값 형식과 참조 형식  (0) 2022.07.15
Chapter2 연습문제  (0) 2022.07.15