---
id: c-data-types-dec
title: "C Decimal Precision"
category: "Programming_Language"
status: "draft"
verification_status: "conceptual"
canonical_id: ""
aliases: ["%.2f", "decimal precision", "C 소수점 자리수"]
duplicate_of: ""
source_trust_level: "B"
confidence_score: 0.84
created_at: 2026-07-04
updated_at: 2026-07-04
review_reason: ""
merge_history: []
tags: ["c", "programming-language", "w3schools", "data-types", "printf", "precision"]
raw_sources: ["https://www.w3schools.com/c/c_data_types_dec.php"]
applied_in: []
github_commit: ""
---

# [[C Decimal Precision]]

## 🎯 한 줄 통찰 (One-line insight)
By default `%f` always pads a float/double out to 6 digits after the decimal point regardless of how few digits the actual value has (`3.5` prints as `3.500000`) — meaning the visible "extra zeros" problem beginners see isn't a bug in their number, it's `%f`'s fixed default precision, controllable only by inserting a `.N` modifier between `%` and `f`. [S1]

## 🧠 핵심 개념 (Core concepts)
- **Default `%f` precision** — always shows 6 digits after the decimal point, padding with zeros if the actual value has fewer. [S1]
- **`.N` precision modifier** — inserting `.N` between `%` and `f` (e.g. `%.2f`) limits output to exactly N digits after the decimal point. [S1]
- **Applies to both float and double** — the precision modifier syntax works the same way regardless of which type is being printed. [S1]

## 📖 세부 내용 (Details)
- Default padding behavior: `float myFloatNum = 3.5; printf("%f\n", myFloatNum); // Outputs 3.500000`. [S1]
- Controlling precision: `printf("%.1f\n", myFloatNum); // Only show 1 digit` / `printf("%.2f\n", myFloatNum); // Only show 2 digits` / `printf("%.4f", myFloatNum); // Only show 4 digits`. [S1]

## ⚖️ 모순 및 업데이트 (Contradictions & updates)
- 현재까지 발견된 모순 사항 없음 (No contradictions found in available sources).

## 🛠️ 적용 사례 (Applied in summary)
현재 발견된 실제 적용 사례가 없습니다 — %.2f로 소수점 둘째 자리까지만 표시하는 것이 통화 금액 출력(다음 Real-Life 예제의 총 비용 계산) 같은 실전 상황에서 표준적으로 쓰인다. [S1]

## 💻 코드 패턴 (Code patterns)
Controlling how many decimal digits printf() shows (C):
```c
float myFloatNum = 3.5;
printf("%f\n", myFloatNum);   // Default: 3.500000
printf("%.1f\n", myFloatNum); // 3.5
printf("%.2f\n", myFloatNum); // 3.50
printf("%.4f", myFloatNum);   // 3.5000
```

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

## 🔗 지식 그래프 (Knowledge Graph)
- **상위/루트:** [[C Tutorial]]
- **관련 개념:** [[C Data Types Characters]], [[C Data Types Extended]], [[C Data Types RealLife]]
- **참조 맥락:** 소수점 정밀도 제어 — 확장 타입(Data Types Extended) 챕터로 이어짐.

## 📚 출처 (Sources)
- [S1] W3Schools — C Decimal Precision — https://www.w3schools.com/c/c_data_types_dec.php

## 📝 변경 이력 (Change history)
- 2026-07-04: Initial draft synthesized from the W3Schools "C Decimal Precision" page (Astra wiki-curation, P-Reinforce v3.1 format).
