进制转换器
在不同进制之间转换数字
最后更新:
关于此工具
进制转换器在十进制、二进制、八进制、十六进制之间互转整数。程序员阅读内存地址、HTTP 字节数时常用十六进制,处理位标志时用二进制,设置 Unix 文件权限 755/644 时用八进制。
使用方法
- Type a number into any of the four fields — decimal, binary, octal, or hex.
- The other three fields update automatically with the equivalent representation.
- Click Copy on any row to grab that representation for your code or terminal.
- Use the leading 0x prefix as appropriate when pasting into source code.
- Watch for invalid input warnings if you mix incompatible characters (e.g., 9 in binary).
常见用例
- Reading a memory address from a stack trace and finding the decimal offset.
- Translating Unix file permissions between symbolic (rwxr-xr-x) and octal (755) form.
- Decoding a network packet field given as hex into the underlying integer value.
- Working with bitmask flags by viewing the binary representation.
- Converting an RGB channel value (0–255) into the hex pair used in a CSS color.
- Checking that a hex constant in your code matches the decimal value in a spec.
常见问题
Q. Why does 10 in hex equal 16 in decimal?
A. Hex (base 16) digits go 0-9 then A-F. Position values are 16⁰, 16¹, … so "10" hex means 1×16 + 0 = 16.
Q. Are negative numbers supported?
A. For most calculator use the tool sticks to non-negative integers. Negative values in binary need an explicit width and two-complement encoding, which differs by platform.
Q. How big a number can I convert?
A. JavaScript handles integers up to 2^53 - 1 safely. Beyond that you need BigInt; this tool focuses on the typical 32/64-bit range.
Q. Why does the hex representation use uppercase letters?
A. Convention only. Lowercase is equally valid (and what JavaScript .toString(16) produces by default). Many specs and tools display uppercase for readability.