정수 (Integer)

분수나 소수 없이 정수(양수, 음수 또는 0)를 나타내는 데이터 유형입니다.

Check Types: 1. Data Type checks. 2. Range checks. 3. Format checks (Regex). 4. Presence checks. 5. Consistency checks. Locations: Client-side (JavaScript), Server-side (API code), Database-level (Constraints).

        graph LR
  Center["정수 (Integer)"]:::main
  Pre_data_type["data-type"]:::pre --> Center
  click Pre_data_type "/terms/data-type"
  Rel_byte["byte"]:::related -.-> Center
  click Rel_byte "/terms/byte"
  Rel_binary["binary"]:::related -.-> Center
  click Rel_binary "/terms/binary"
  classDef main fill:#7c3aed,stroke:#8b5cf6,stroke-width:2px,color:white,font-weight:bold,rx:5,ry:5;
  classDef pre fill:#0f172a,stroke:#3b82f6,color:#94a3b8,rx:5,ry:5;
  classDef child fill:#0f172a,stroke:#10b981,color:#94a3b8,rx:5,ry:5;
  classDef related fill:#0f172a,stroke:#8b5cf6,stroke-dasharray: 5 5,color:#94a3b8,rx:5,ry:5;
  linkStyle default stroke:#4b5563,stroke-width:2px;

      

🧒 5살도 이해할 수 있게 설명

정수(Integer)는 손가락을 셀 때 사용하는 평범한 숫자입니다. 절반도 없고, 4분의 1도 없고, 소수점도 없습니다. 사과 3개나 -3개(빚진 경우)를 가질 수는 있지만 3.5개를 가질 수는 없습니다!

🤓 Expert Deep Dive

정수는 일반적으로 2의 보수를 사용하여 저장되므로 음수 산술이 간단해집니다. 부호 있는(signed) 정수는 부호에 1비트를 사용합니다. 부호 없는(unsigned) 정수는 양수만 저장하여 상한 범위를 두 배로 늘립니다. 임의 정밀도 정수(BigInt)는 메모리 한계까지 커질 수 있습니다. 정수 나눗셈은 결과를 버림(truncate)합니다.

🔗 관련 용어

선행 지식:

📚 출처