시간/숫자
IEEE 754 부동소수점 변환기
10진수 ↔ IEEE 754 이진 표현(단정밀도 또는 배정밀도) — 부호, 지수, 가수, 특수 값.
Computers store fractional numbers in binary under the IEEE 754 standard — a sign, an exponent, and a mantissa, packed into a fixed number of bits. This tool shows that representation for any decimal number and parses it back into a number.
How to use it
- Number → bits: enter a decimal number to get its breakdown into sign, exponent, and mantissa for single (32-bit) or double (64-bit) precision.
- Bits → number: paste a bit representation to get the decimal value back.
- Special values (infinity, NaN, signed zero) are recognized and explained separately.
Common uses
- Understanding why 0.1 + 0.2 doesn't exactly equal 0.3 in most programming languages — a concrete demonstration of rounding error.
- Studying float's internal representation to understand precision limits in financial or scientific calculations.
- Parsing a binary dump or network packet where numbers are transmitted in IEEE 754 format.
Things to keep in mind
Most decimal fractions (0.1, for example) have no exact binary representation — that's the root cause of the typical rounding errors seen in calculation results.
Comparing floating-point numbers for exact equality (===) is unreliable — check instead whether the difference is smaller than a small threshold (epsilon).
자주 묻는 질문
단정밀도와 배정밀도의 차이는 무엇인가요?
단정밀도(float, 32비트)는 약 7자리의 십진 정밀도를 제공하고, 배정밀도(double, 64비트)는 약 15-17자리를 제공합니다. JavaScript의 Number 타입은 배정밀도를 사용합니다.
일부 소수는 왜 정밀도를 잃나요?
IEEE 754는 숫자를 이진수로 저장하며, 많은 십진 분수(0.1 등)는 정확한 유한 이진 표현이 없습니다 — 따라서 아주 작은 반올림 오차와 함께 가장 가까운 가능한 값이 저장됩니다.
NaN, Infinity, -0은 무엇을 의미하나요?
NaN은 0/0과 같은 잘못된 연산의 결과입니다. Infinity/-Infinity는 값이 표현 가능한 범위를 초과할 때(예: 0으로 나누기) 나타납니다. +0과 -0은 부호 있는 0의 서로 다른 두 비트 표현이지만, 숫자로서는 동일합니다.
비정규화(subnormal) 숫자란 무엇인가요?
일반적인 형식으로 표현하기에는 절대값이 너무 작은 숫자를 위한 특수 모드입니다 — 가수의 암묵적인 1이 제거되어 정밀도 일부를 잃는 대가로 0에 점진적으로 가까워질 수 있습니다.
정확한 동등성 대신 소수를 올바르게 비교하는 방법은 무엇인가요?
a === b 대신 두 숫자의 차이가 작은 임계값(엡실론)보다 작은지 확인합니다: Math.abs(a - b) < 1e-9. 반올림 오차 때문에 정확한 동등성은 거의 보장되지 않습니다.