基数間で数値を変換する
整数を 2 進、8 進、10 進、16 進、および任意の基数の間で変換します。
问题
ある基数(例:16 進)の数値を、別のツールや文脈で使うために別の基数(例:2 進や 10 進)に変換する必要があります。
前提条件
- 位取り記数法の理解
- 基本的な算術
ステップ
-
1. Identify the source and target radix
Determine the base of your input number and the base you need as output. Common radices are 2 (binary), 8 (octal), 10 (decimal), and 16 (hex). The source value must be valid in its claimed base.
入力source: hex 1A | target: binary输出radices: 16 → 2 -
2. Convert through decimal or directly
The simplest method is to first parse the input as a decimal integer, then format that integer in the target base. For direct hex-to-binary, each hex digit maps to 4 bits without intermediate conversion.
入力1A (hex)输出26 (decimal) → 11010 (binary) -
3. Verify the result
Convert the output back to the original base and confirm it matches the input. Check that no digits in the output exceed the target radix (e.g., no digit 8 in octal).
入力11010 (binary)输出1A (hex) ✓
期待される結果
同じ数値を目的の基数で表したもの。すべての桁がその基数で有効になります。
よくあるエラー
- Using digits invalid for the source base
- Hex allows A-F, but binary only allows 0-1. Validate the input before converting.
- Losing leading zeros
- Leading zeros are significant in fixed-width contexts like byte representations. Pad the output to the required width after conversion.
トラブルシューティング指引
- If the result seems too large or small, double-check the source radix. A hex value read as decimal will be wrong.
- For fractional numbers, note that this tutorial covers integers only; fractional conversion requires separate handling.
セキュリティ上の制限
- Pure arithmetic conversion with no security implications.
関連ツール
基数変換ツール
Convert numbers between any base (2-36)。無料、プライベート、100%クライアントサイド。 ツール
HEX エンコーダー
Encode text to hexadecimal online。無料、プライベート、100%クライアントサイド。 ツール
バイナリエンコーダー
Encode text to binary (base-2) online。無料、プライベート、100%クライアントサイド。 ツール
8進数エンコーダー
Convert text to octal (base-8) byte representation。無料、プライベート、100%クライアントサイド。 ツール