๋ณ์ Variables
์์น ๋ฐ ๋ฌธ์์ด์ ์ ์ฅํ๊ธฐ ์ํ ์ฅ์๋ฅผ ๋ณ์๋ผ ํ๋ค.
์ด๋ค์ ์ข ๋ฅ์ ๋ฐ๋ผ ํฌ๊ธฐ์ ํํ๋ฒ์๊ฐ ์๋ก ๋ค๋ฅด๊ธฐ ๋๋ฌธ์ ๋ชฉ์ ์ ๋ง๋ ๋ฐ์ดํฐ ํ์ ์ ์ฐ๋ ๊ฒ์ด ์ค์ํ๋ค.
๋ณ์๋ ํํ์ ๋ฐ๋ผ ์ ์ํ(Integer types)๊ณผ ์ค์ํ(Floating-point types)์ผ๋ก ๋ถ๋ฅ๋๋ฉฐ, ๋ถํธ๋ฅผ ๊ณ ๋ คํ ๊ฒ์ธ์ง์ ๋ฐ๋ผ signed, unsigned๋ก ๊ตฌ๋ณํ๋ค.
Integer Types
Data type |
bit |
byte (B) |
Value range |
(signed) char |
8 |
1 |
-27 to 27-1 |
unsigned char |
0 to 28 | ||
(signed) int |
32 |
4 |
-231 to 231 -1 |
unsigned int | 0 to 232 | ||
(signed) short | 16 | 2 |
-215 to 215-1 |
unsigned short | 0 to 216 | ||
(signed) long |
32 | 4 |
-231 to 231 -1 |
unsigned long |
0 to 232 |
Floting-Point Types
Data type |
bit |
byte (B) |
Value range |
Precision |
float |
32 |
4 |
1.2E-38 to 3.4E+38 |
6 decimal places |
double |
64 |
8 |
2.3E-308 to 1.7E+308 |
15 decimal places |
long double |
80 |
10 |
3.4E-4932 to 1.1E+4932 |
19 decimal places |
โป ๋ณ์๋ช ์ ์ซ์๋ก ์์ํ ์ ์๋ค.
๋ฌธ์๋ฅผ ํ๊ธฐํ๋ ASCII์ฝ๋ ๊ฐ์ ๋ฌธ์ ์ฝ๋๋ก ๊ตฌ์ฑ๋ ๊ฒฝ์ฐ๋ฅผ ๋ฌธ์์ด์ด๋ผ๊ณ ํ๋ค. ๊ทธ๋ฌ๋ ๋ฌธ์๋ ๊ธฐํ ๋ฐ์ด๋๋ฆฌ ์ซ์ ๋ชจ๋ ์ ์ํ์ผ๋ก ์ทจ๊ธํ๋ค. ๋ฐ๋ผ์ ๋ฌธ์์ด์ด๋ผ๊ณ ํน๋ณํ ๊ฒ์ ์์ง๋ง ๋ฌธ์๋ง์ ์ํ ๊ท์ ์ด ์๋ค. ์๋ฅผ ๋ค์ด "kim"์ด๋ผ๊ณ ๊ท์ ํ๋ค๋ฉด ASCII 3๊ฐ๋ฌธ์์ 4๋ฒ์งธ ๋์ ์๋ฆฌ๋ 0์ด ๊ฒฐํฉ๋ 4 byte ์ด๋ค. ๋ฐ๋ผ์ ๋ฐฐ์ด์ ๋ฃ์ผ๋ ค๋ฉด 4 byte ์ด์์ด ์์ด์ผ ํ๋ค. ํ์ผ์ ๋ฌธ์์ด์ ํํํ๋ ๋ฐฉ์์๋ ASCII์ Unicode ๋ฐฉ์์ด ์๋ค.
์์คํค ASCII
์๋ฌธ/์ซ์ 1๊ธ์๋ 1๋ฐ์ดํธ, ํ๊ธ/ํ์ 1๊ธ์๋ 2๋ฐ์ดํธ์ด๋ค.
์ปดํจํฐ ์ด์ฐฝ๊ธฐ๋ถํฐ ์ฌ์ฉ๋์ด ํธํ์ฑ์ด ์ข๋ค.
ํ๋์ ์ธ์ฝ๋ฉ ๋น, ์๋ฌธ๊ณผ ๋ ๋ค๋ฅธ ํ๋์ ์ธ์ด๋ง ์ฌ์ฉํ ์ ์์ด์ ํ๋์ ํ์ผ์ ์ฌ๋ฌ ์ธ์ด๋ฅผ ๋์์ ํํํ๊ธฐ ํ๋ค๋ค. (euc-kr์ ๊ฒฝ์ฐ ์๋ฌธ, ํ๊ธ, ํ์)
์ ๋์ฝ๋ Unicode
๋ชจ๋ ์ผ๋ฐ์ ์ธ ๊ธ์๋ ์ด๋ก ์ ์ผ๋ก 2๋ฐ์ดํธ์ด๋ค.
๋จ, UTF-8 ์ ๋์ฝ๋๊ฐ ํ์ผ์ ์ ์ฅ ๋ ๋, ์๋ฌธ/์ซ์๋ ์์คํค ์ฝ๋์ ๋ง์ฐฌ๊ฐ์ง๋ก 1๋ฐ์ดํธ๋ฅผ ์ฌ์ฉํ๊ณ , ํ๊ธ์ 3๋ฐ์ดํธ๋ก ํ์ผ์ ์ ์ฅ๋๋ค.
๊ฐ ์ธ์ด์ ํด๋นํ๋ ํฐํธ๊ฐ ์ค์น๋์ด ์์ผ๋ฉด ์ ์ธ๊ณ์ ๋ชจ๋ ์ธ์ด๋ฅผ ํ๋์ ํ์ผ์ ์ธ ์ ์๋ค.
์นํ์ด์ง์ ๊ฒฝ์ฐ ์ฃผ๋ก ์ ๋์ฝ๋๋ฅผ ์ฌ์ฉํ๋ค.
- http://ko.wikipedia.org/wiki/Char [๋ณธ๋ฌธ์ผ๋ก]
'ํ๋ก๊ทธ๋๋ฐ' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
์ด์ ์ฒด์ ์ ๋ถ๋ฅ (0) | 2015.03.03 |
---|---|
์์ฌ๋์ Pseudo-Random Number (0) | 2015.03.03 |
๊ธฐ์๋ฒ ๋ฐ ์ฐ์ ์ฐ์ฐ Number system and Arithmetic Operation (0) | 2015.03.03 |
[tbd] ๋ฉ๋ชจ๋ฆฌ ์์ญ (0) | 2015.03.03 |
[tbd] ์ปดํจํฐ ์ธ์ด Computer Language (0) | 2015.03.03 |