1cfd3bbb56
Topic_CSS/Topic_HTML/Topic_JavaScript/Topic_Prompt/Topic_Comfyui 등 기존 카테고리 폴더를 정리하고, Topic_Graphic/Dev 등 신규 산출물과 Topics 내부 세션/메모리 기록을 동기화.
3.9 KiB
3.9 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 | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| java-operators-arithmetic | Java Operators Arithmetic | Programming_Language | draft | conceptual |
|
B | 0.9 | 2026-07-04 | 2026-07-04 |
|
|
Java Operators Arithmetic
🎯 한 줄 통찰 (One-line insight)
Dividing two int values ALWAYS truncates to an integer result (10 / 3 gives 3, not 3.33) — getting a decimal result requires both operands to be double, making this a common source of silent precision loss for beginners. [S1]
🧠 핵심 개념 (Core concepts)
- Arithmetic operators —
+,-,*,/,%(modulus),++(increment),--(decrement). [S1] - Integer division truncates —
int / intalways yields anint, discarding any remainder. [S1] - Double division preserves decimals —
double / doubleyields the actual fractional result. [S1] ++/--— increase/decrease a variable by exactly 1. [S1]- Increment then decrement cancels out — ending value equals the starting value. [S1]
🧩 추출된 패턴 (Extracted patterns)
- Integer division truncation is the classic footgun —
10 / 3silently gives3in Java (as in most statically-typed languages), unlike Python 3 where/always returns a float; this difference trips up developers moving between languages. [S1] - Counter pattern via ++/-- — tracking a running count (e.g. people entering/leaving a room) is the canonical real-world use of increment/decrement. [S1]
📖 세부 내용 (Details)
- All operators demoed:
int x = 10; int y = 3; println(x + y); println(x - y); println(x * y); println(x / y); println(x % y);. [S1] - Integer vs. double division:
int a = 10; int b = 3; System.out.println(a / b); // 3 (truncated)vs.double c = 10.0d; double d = 3.0d; System.out.println(c / d); // 3.333.... [S1] - Increment/decrement counter:
int peopleInRoom = 0; peopleInRoom++; peopleInRoom++; peopleInRoom--;. [S1]
⚖️ 모순 및 업데이트 (Contradictions & updates)
- 정수 나눗셈의 절삭 동작:
int / int는 항상 정수 결과를 반환하며 소수점 이하는 버려진다는 점이 명시적으로 경고됨 — Type Casting 챕터의 double 캐스팅 해법과 연결된다. [S1]
🛠️ 적용 사례 (Applied in summary)
현재 발견된 실제 적용 사례가 없습니다 — 사람 수 카운팅 같은 실전 예제에서 증감 연산자의 용도가 직접 등장한다. [S1]
💻 코드 패턴 (Code patterns)
Integer division truncates, double division doesn't (Java):
int a = 10, b = 3;
System.out.println(a / b); // 3 (truncated)
double c = 10.0d, d = 3.0d;
System.out.println(c / d); // 3.333...
✅ 검증 상태 및 신뢰도
- 상태: draft
- 검증 단계: conceptual
- 출처 신뢰도: B (W3Schools — widely used educational reference, not a primary standards body)
- 신뢰 점수: 0.90
- 중복 검사 결과: 신규 생성 (New discovery)
🔗 지식 그래프 (Knowledge Graph)
- 상위/루트: Java Tutorial
- 관련 개념: Java Operators, Java Type Casting, Java Numbers
- 참조 맥락: 정수 나눗셈 절삭 문제는 Type Casting 챕터의 double 캐스팅 해법과 직접 연결된다.
📚 출처 (Sources)
- [S1] W3Schools — Java Arithmetic Operators — https://www.w3schools.com/java/java_operators_arithmetic.asp
📝 변경 이력 (Change history)
- 2026-07-04: Initial draft synthesized from the W3Schools "Java Arithmetic Operators" page (Astra wiki-curation, P-Reinforce v3.1 format).