時間/数値
IEEE 754浮動小数点コンバーター
10進数 ↔ IEEE 754 2進数表現(単精度または倍精度) — 符号、指数部、仮数部、特殊値。
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桁の10進精度を、倍精度(double、64ビット)は約15〜17桁を与えます。JavaScriptのNumber型は倍精度を使用します。
なぜ一部の10進数が精度を失うのですか?
IEEE 754は数値を2進数で保存しますが、多くの10進小数(0.1など)には正確な有限の2進表現がありません — そのため、わずかな丸め誤差を伴う最も近い可能な値が保存されます。
NaN、Infinity、-0は何を意味しますか?
NaNは0/0のような無効な演算の結果です。Infinity/-Infinityは値が表現可能な範囲を超えたとき(0での除算など)に現れます。+0と-0は符号付きゼロの2つの異なるビット表現ですが、数値としては等しいです。
非正規化数(subnormal)とは何ですか?
通常の形式には大きさが小さすぎる数値のための特別な表現モードです——仮数部の暗黙の先頭1が省略され、精度の一部を犠牲にして段階的にゼロに近づくことができます。
厳密な等価性のチェックの代わりに、分数を正しく比較するにはどうすればよいですか?
a === bの代わりに、数値の差が小さなしきい値(イプシロン)より小さいかどうかを確認します: Math.abs(a - b) < 1e-9。丸め誤差のため、厳密な等価性が保証されることはほとんどありません。