Data Type - Unity2033/Research GitHub Wiki

μžλ£Œν˜•μ΄λž€?

  • 데이터λ₯Ό μ €μž₯ν•˜κΈ° μœ„ν•΄ λ°μ΄ν„°μ˜ ν˜•νƒœλ₯Ό μ •ν•΄μ£ΌλŠ” κ²ƒμž…λ‹ˆλ‹€.
μžλ£Œν˜• 크기 (λ°”μ΄νŠΈ) ν‘œν˜„ λ²”μœ„
char 1 -128 ~ 127
short 2 -32,768 ~ 32,767
int 4 -2,147,483,648 ~ 2,147,483,647
long 4 -2,147,483,648 ~ 2,147,483,647
long long 8 -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807
float 4 1.2E-38 ~ 3.4E+38
double 8 2.3E-308 ~ 1.7E+308
  • μžλ£Œν˜•μ€ 각각의 μžλ£Œν˜•λ§ˆλ‹€ 크기가 μ •ν•΄μ Έ 있으며, μžλ£Œν˜•μ˜ ν¬κΈ°λŠ” λ°”μ΄νŠΈ λ‹¨μœ„λ‘œ 이루어져 μžˆμŠ΅λ‹ˆλ‹€.

  • μžλ£Œν˜•μ˜ 경우 μžλ£Œν˜•μ— 따라 μ €μž₯ν•  수 μžˆλŠ” κ°’μ˜ μ’…λ₯˜μ™€ λ²”μœ„κ°€ κ²°μ •λ˜μ–΄ μžˆμŠ΅λ‹ˆλ‹€.

Unsigned Data Type

  • μ •μˆ˜ 값을 μ €μž₯ν•  수 μžˆλŠ” μžλ£Œν˜• μ€‘μ—μ„œ, λΆ€ν˜Έ λΉ„νŠΈ 없이 μ–‘μ˜ μ •μˆ˜μ™€ 0λ§Œμ„ ν‘œν˜„ν•˜λŠ” μžλ£Œν˜•μž…λ‹ˆλ‹€.
μžλ£Œν˜• 크기 ν‘œν˜„ λ²”μœ„
unsigned char 1 λ°”μ΄νŠΈ 0 ~ 255
unsigned short 2 λ°”μ΄νŠΈ 0 ~ 65,535
unsigned int 4 λ°”μ΄νŠΈ 0 ~ 4,294,967,295
unsigned long 4 λ°”μ΄νŠΈ (Windows κΈ°μ€€) 0 ~ 4,294,967,295
unsigned long long 8 λ°”μ΄νŠΈ 0 ~ 18,446,744,073,709,551,615
  • μ‹€μˆ˜λŠ” IEEE 754 ꡬ쑰가 λΆ€ν˜Έ λΉ„νŠΈλ₯Ό ν¬ν•¨ν•˜κ³  μžˆμœΌλ―€λ‘œ, λΆ€ν˜Έ 없이 μ‚¬μš©ν•  수 μ—†μŠ΅λ‹ˆλ‹€.

Implicit Type Conversion

  • μžλ™μœΌλ‘œ ν•˜λ‚˜μ˜ μžλ£Œν˜•μ„ λ‹€λ₯Έ μžλ£Œν˜•μœΌλ‘œ λ³€ν™˜ν•˜λŠ” κ³Όμ •μž…λ‹ˆλ‹€.
#include <stdio.h>

void main()
{
    int integer = 10;
    float decimal = 7.5f;

    printf("The result of the calculation between an integer variable and a decimal variable : %d", integer + decimal);
}
  • μ„œλ‘œ λ‹€λ₯Έ μžλ£Œν˜•μœΌλ‘œ 연산이 μ΄λ£¨μ–΄μ§ˆ λ•Œ μžλ£Œν˜•μ˜ 크기가 큰 μžλ£Œν˜•μœΌλ‘œ λ³€ν™˜λ©λ‹ˆλ‹€.

Explicit Type Conversion

  • 연산이 이루어지기 전에 μ‚¬μš©μž 직접 μžλ£Œν˜•μ„ λ³€ν™˜ν•˜λŠ” κ³Όμ •μž…λ‹ˆλ‹€.
#include <stdio.h>

void main()
{
    int math = 85;
    int science = 70;
 
    float average = ((float)math +  science) / 2;

    printf("The value of the variable : %f", average);
}
⚠️ **GitHub.com Fallback** ⚠️