Files
2nd/10_Wiki/Dev/Topic_CPP/CPP_Operators_Arithmetic.md
T
Antigravity Agent 1cfd3bbb56 docs(10_Wiki): 위키 구조 정리 — 언어 튜토리얼 카테고리 폴더 제거 + 신규 자산 동기화
Topic_CSS/Topic_HTML/Topic_JavaScript/Topic_Prompt/Topic_Comfyui 등 기존 카테고리 폴더를 정리하고,
Topic_Graphic/Dev 등 신규 산출물과 Topics 내부 세션/메모리 기록을 동기화.
2026-07-05 00:10:59 +09:00

3.5 KiB

id, title, category, status, verification_status, canonical_id, aliases, duplicate_of, source_trust_level, confidence_score, created_at, updated_at, review_reason, merge_history, tags, raw_sources, applied_in, github_commit
id title category status verification_status canonical_id aliases duplicate_of source_trust_level confidence_score created_at updated_at review_reason merge_history tags raw_sources applied_in github_commit
cpp-operators-arithmetic C++ Arithmetic Operators Programming_Language draft conceptual
integer division
increment decrement
C++ 산술 연산자
B 0.85 2026-07-04 2026-07-04
cpp
programming-language
w3schools
operators
arithmetic
https://www.w3schools.com/cpp/cpp_operators_arithmetic.asp

CPP Arithmetic Operators

🎯 한 줄 통찰 (One-line insight)

Integer division truncation carries over from C completely unchanged — 10 / 3 still yields 3 in C++, and the fix is identical too (use double operands: 10.0 / 3 gives 3.333...) — confirming that C++'s arithmetic semantics for the basic numeric types are inherited from C wholesale, not just its syntax. [S1]

🧠 핵심 개념 (Core concepts)

  • Seven core arithmetic operators+, -, *, /, % (modulus), ++ (increment), -- (decrement) — identical set to C. [S1]
  • Integer division truncation — dividing two ints always yields an int, discarding any decimal remainder; use double operands for a decimal result. [S1]
  • Increment/decrement round-trip — incrementing then decrementing the same variable returns it to its original value. [S1]

📖 세부 내용 (Details)

  • All seven operators demonstrated with chained cout output: int x = 10; int y = 3; cout << (x + y) << "\n"; // 13 ... cout << (x % y) << "\n"; // 1. [S1]
  • Integer vs decimal division contrast: int x = 10; int y = 3; cout << (x / y); // 3 (integer division) versus double a = 10.0; double b = 3.0; cout << (a / b); // 3.333.... [S1]
  • Real-life counting example: int peopleInRoom = 0; peopleInRoom++; peopleInRoom++; peopleInRoom++; // 3 people enter cout << peopleInRoom; // 3 then peopleInRoom--; // 2. [S1]

⚖️ 모순 및 업데이트 (Contradictions & updates)

  • C와 완전히 동일한 정수 나눗셈 절삭: int끼리 나누면 소수점이 버려진다는 점과 그 해결책(double 사용)이 C 챕터와 동일하게 확인됨. [S1]

🛠️ 적용 사례 (Applied in summary)

방에 들어오고 나가는 사람 수를 ++/--로 세는 카운터 예제가 원문에서 직접 실전 활용 사례로 제시됨(C 챕터와 동일한 예제). [S1]

💻 코드 패턴 (Code patterns)

Integer division truncates; use double operands for a decimal result (C++):

int x = 10;
int y = 3;
cout << (x / y); // Integer division, result is 3

double a = 10.0;
double b = 3.0;
cout << (a / b); // Decimal division, result is 3.333...

검증 상태 및 신뢰도

  • 상태: draft
  • 검증 단계: conceptual
  • 출처 신뢰도: B (W3Schools — widely used educational reference, not a primary standards body)
  • 신뢰 점수: 0.85
  • 중복 검사 결과: 신규 생성 (New discovery)

🔗 지식 그래프 (Knowledge Graph)

📚 출처 (Sources)

📝 변경 이력 (Change history)

  • 2026-07-04: Initial draft synthesized from the W3Schools "C++ Arithmetic Operators" page (Astra wiki-curation, P-Reinforce v3.1 format).