본문 바로가기
프로그래밍

1_3.접미어와 MaxValue/MinValue

by BlueOcean&Shark 2019. 1. 6.
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace cshapExOne5
{
    class Program
    {
        static void Main(string[] args)
        {
            // char - 2바이트
            char a = 'a';
            char b = 'b';
            char c = 'c';
            char d = 'd';
            char e = 'e';
            Console.Write(a);
            Console.Write(b);
            Console.Write(c);
            Console.Write(d);
            Console.Write(e);
 
            // string - 가변의 크기
            string str = "abcde";
            Console.Write(str);
            
 
            /*
             * C# 컴파일러는 int, double, char, string, bool 
             * 데이터 타입에는 기본적으로 그에 해당하는 값을 할당
             * 
             * int, double, char, string, bool 이외의 자료형에는
             * 데이터 타입별 접미사를 지정하여 사용
             * 
             * ex) 11.11 은 double을 기본으로 할당하지만 
             * float로 하고싶다면 11.11f 와같이 점미사를 사용
             * 
             * [접미어]
             * l : long
             * u : uint
             * ul : ulong
             * f : float
             * d : double
             * m : decimal             
             */
 
            int maxi = int.MaxValue; // int형의 최대치
            int mini = int.MinValue; // int형의 최소치
            Console.WriteLine(maxi);
            Console.WriteLine(mini);
 
            long maxl = long.MaxValue; // long형의 최대치
            long minl = long.MinValue; // long형의 최소치
            Console.WriteLine(maxl);
            Console.WriteLine(minl);
 
            double maxd = double.MaxValue; // double형의 최대치
            double mind = double.MinValue; // double형의 최소치
            Console.WriteLine(maxd);
            Console.WriteLine(mind);
 
            Console.ReadKey();
        }
    }
}
 
cs

------------------결과창----------------------------------------

abcdeabcde2147483647

-2147483648

9223372036854775807

-9223372036854775808

1.79769313486232E+308

-1.79769313486232E+308

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

1_5.reference타입  (0) 2019.01.07
1_4.null과 nullable ( reference타입/value타입 )  (0) 2019.01.06
1_2.자료형과 변수선언  (0) 2019.01.06
1_1.Console.WriteLine  (0) 2019.01.06
1. mysql [show / use / select / create / drop]  (0) 2018.04.06

댓글