--- id: c-math title: "C Math Functions" category: "Programming_Language" status: "draft" verification_status: "conceptual" canonical_id: "" aliases: ["math.h", "sqrt ceil floor pow", "C μˆ˜ν•™ ν•¨μˆ˜"] duplicate_of: "" source_trust_level: "B" confidence_score: 0.83 created_at: 2026-07-04 updated_at: 2026-07-04 review_reason: "" merge_history: [] tags: ["c", "programming-language", "w3schools", "math", "math.h"] raw_sources: ["https://www.w3schools.com/c/c_math.php"] applied_in: [] github_commit: "" --- # [[C Math Functions]] ## 🎯 ν•œ 쀄 톡찰 (One-line insight) `ceil()` and `floor()` both return a `float`/`double`, NOT an `int` β€” printing `ceil(1.4)` with `%f` still shows a decimal-formatted result (`2.000000`), meaning "rounding" in C's math library doesn't convert the value to an integer type; it just replaces the fractional part while preserving the floating-point representation, so further formatting or casting is still the caller's job. [S1] ## 🧠 핡심 κ°œλ… (Core concepts) - **``** β€” required header for math functions beyond basic arithmetic operators. [S1] - **`sqrt(x)`** β€” returns the square root of `x`. [S1] - **`ceil(x)`** β€” rounds UP to the nearest integer value (still returned as a float/double). [S1] - **`floor(x)`** β€” rounds DOWN to the nearest integer value (still returned as a float/double). [S1] - **`pow(x, y)`** β€” returns x raised to the power of y (xΚΈ). [S1] ## πŸ“– μ„ΈλΆ€ λ‚΄μš© (Details) - Square root: `printf("%f", sqrt(16));`. [S1] - Rounding up vs down on the same value: `printf("%f", ceil(1.4)); printf("%f", floor(1.4));` β€” ceil gives 2.000000, floor gives 1.000000. [S1] - Exponentiation: `printf("%f", pow(4, 3));` β€” 4Β³ = 64. [S1] ## βš–οΈ λͺ¨μˆœ 및 μ—…λ°μ΄νŠΈ (Contradictions & updates) - ν˜„μž¬κΉŒμ§€ 발견된 λͺ¨μˆœ 사항 μ—†μŒ (No contradictions found in available sources). ## πŸ› οΈ 적용 사둀 (Applied in summary) ν˜„μž¬ 발견된 μ‹€μ œ 적용 사둀가 μ—†μŠ΅λ‹ˆλ‹€ β€” sqrt/ceil/floor/powλŠ” κ²Œμž„ λ‘œμ§μ΄λ‚˜ κ·Έλž˜ν”½ 계산 λ“±μ—μ„œ ν”νžˆ κ²°ν•©ν•΄ μ“°μ΄λŠ” κΈ°λ³Έ μˆ˜ν•™ ν•¨μˆ˜ 집합이닀. [S1] ## πŸ’» μ½”λ“œ νŒ¨ν„΄ (Code patterns) Rounding up and down, both still returned as floating-point values (C): ```c #include printf("%f", ceil(1.4)); // 2.000000 printf("%f", floor(1.4)); // 1.000000 ``` ## βœ… 검증 μƒνƒœ 및 신뒰도 - **μƒνƒœ:** draft - **검증 단계:** conceptual - **좜처 신뒰도:** B (W3Schools β€” widely used educational reference, not a primary standards body) - **μ‹ λ’° 점수:** 0.83 - **쀑볡 검사 κ²°κ³Ό:** μ‹ κ·œ 생성 (New discovery) ## πŸ”— 지식 κ·Έλž˜ν”„ (Knowledge Graph) - **μƒμœ„/루트:** [[C Tutorial]] - **κ΄€λ ¨ κ°œλ…:** [[C Strings Functions]], [[C Random Numbers]] - **μ°Έμ‘° λ§₯락:** μˆ˜ν•™ ν•¨μˆ˜ β€” λ‚œμˆ˜ 생성(Random Numbers) μ±•ν„°λ‘œ 이어짐. ## πŸ“š 좜처 (Sources) - [S1] W3Schools β€” C Math Functions β€” https://www.w3schools.com/c/c_math.php ## πŸ“ λ³€κ²½ 이λ ₯ (Change history) - 2026-07-04: Initial draft synthesized from the W3Schools "C Math Functions" page (Astra wiki-curation, P-Reinforce v3.1 format).