--- id: php-numbers title: "PHP Numbers" category: "Programming_Language" status: "draft" verification_status: "conceptual" canonical_id: "" aliases: ["is_int", "is_float", "NAN", "PHP 숫자"] duplicate_of: "" source_trust_level: "B" confidence_score: 0.9 created_at: 2026-07-04 updated_at: 2026-07-04 review_reason: "" merge_history: [] tags: ["php", "programming", "w3schools", "numbers"] raw_sources: ["https://www.w3schools.com/php/php_numbers.asp"] applied_in: [] github_commit: "" --- # [[PHP Numbers]] ## 🎯 ν•œ 쀄 톡찰 (One-line insight) `4 * 2.5` results in a FLOAT (10.0), not an integer, even though the mathematical result is a whole number β€” PHP's rule is that if ANY operand in an arithmetic expression is a float, the result is always stored as float, regardless of whether the value happens to be whole. [S1] ## 🧠 핡심 κ°œλ… (Core concepts) - **Three numeric types** β€” Integer, Float, Numeric Strings; plus Infinity and NaN as special number-related values. [S1] - **`is_int()` / `is_float()`** β€” type checks. [S1] - **Integer range** β€” platform-dependent (32-bit: Β±2,147,483,647; 64-bit: much larger); overflow silently becomes a float. [S1] - **Integer notations** β€” decimal, hex (`0x`), octal (`0`), binary (`0b`). [S1] - **`PHP_INT_MAX` / `PHP_INT_MIN` / `PHP_INT_SIZE`** β€” predefined integer limit constants. [S1] - **`PHP_FLOAT_MAX` / `MIN` / `DIG` / `EPSILON`** (PHP 7.2+) β€” predefined float precision constants. [S1] - **`is_finite()` / `is_infinite()`** β€” range checks against platform float limits. [S1] - **`NAN`** ("Not A Number") β€” returned by invalid math operations; checked via `is_nan()`. [S1] - **`is_numeric()`** β€” true for both actual numbers AND numeric strings (e.g., `"5985"`). [S1] - **`intval()`** β€” extracts the integer value from a float or numeric-leading string. [S1] ## πŸ“– μ„ΈλΆ€ λ‚΄μš© (Details) - Float contagion rule: `4 * 2.5` is 10, but stored as float because one operand (2.5) is a float. [S1] - Invalid math yields NAN: `$x = acos(8); var_dump($x); var_dump(is_nan($x)); // true`. [S1] - Numeric string check: `$x = "59.85" + 100; var_dump(is_numeric($x)); // true (arithmetic result)`. [S1] - intval on string: `$x = "23465.768"; echo intval($x); // 23465`. [S1] ## βš–οΈ λͺ¨μˆœ 및 μ—…λ°μ΄νŠΈ (Contradictions & updates) - **λΆ€λ™μ†Œμˆ˜μ  μ „μ—Ό κ·œμΉ™**: μ—°μ‚° κ²°κ³Όκ°€ μ •μˆ˜ 값이어도 ν”Όμ—°μ‚°μž 쀑 ν•˜λ‚˜κ°€ float이면 κ²°κ³Ό νƒ€μž…μ€ 항상 float이 λœλ‹€λŠ” 점이 λͺ…μ‹œμ μœΌλ‘œ 강쑰됨. [S1] ## πŸ› οΈ 적용 사둀 (Applied in summary) ν˜„μž¬ 발견된 μ‹€μ œ 적용 사둀가 μ—†μŠ΅λ‹ˆλ‹€ β€” is_numeric()으둜 μ‚¬μš©μž μž…λ ₯이 숫자 ν˜•νƒœμΈμ§€ κ²€μ¦ν•˜λŠ” 것이 폼 처리의 μ‹€μ „ νŒ¨ν„΄μ΄λ‹€. [S1] ## πŸ’» μ½”λ“œ νŒ¨ν„΄ (Code patterns) Float contagion in arithmetic (PHP): ```php $result = 4 * 2.5; var_dump($result); // float(10) β€” not int, because 2.5 is a float ``` ## βœ… 검증 μƒνƒœ 및 신뒰도 - **μƒνƒœ:** draft - **검증 단계:** conceptual - **좜처 신뒰도:** B (W3Schools β€” widely used educational reference, not a primary standards body) - **μ‹ λ’° 점수:** 0.90 - **쀑볡 검사 κ²°κ³Ό:** μ‹ κ·œ 생성 (New discovery) ## πŸ”— 지식 κ·Έλž˜ν”„ (Knowledge Graph) - **μƒμœ„/루트:** [[PHP Tutorial]] - **κ΄€λ ¨ κ°œλ…:** [[PHP Data Types]], [[PHP Casting]], [[PHP Math]] - **μ°Έμ‘° λ§₯락:** 숫자 νƒ€μž…μ˜ μ„ΈλΆ€ κ·œμΉ™ β€” μΊμŠ€νŒ…(Casting)/μˆ˜ν•™ν•¨μˆ˜(Math) μ±•ν„°λ‘œ 이어짐. ## πŸ“š 좜처 (Sources) - [S1] W3Schools β€” PHP Numbers β€” https://www.w3schools.com/php/php_numbers.asp ## πŸ“ λ³€κ²½ 이λ ₯ (Change history) - 2026-07-04: Initial draft synthesized from the W3Schools "PHP Numbers" page (Astra wiki-curation, P-Reinforce v3.1 format).