二进制转八进制转换器

这个二进制转八进制转换器使用 3 位分组方法,将二进制(基数 2)数转换为八进制(基数 8)数值。输入任意二进制数,即可查看对应的八进制结果,并附有可视化分解,展示每组三位二进制数如何映射到一个八进制数字。

Binary to Octal Converter

Convert binary numbers (base-2) to octal numbers (base-8)

Frequently Asked Questions

如何将二进制转换为八进制?

从右侧开始,将二进制数字分成每组三位。如果最左边的组少于三位,用前导零填充。然后将每个3位组转换为对应的八进制数(000=0、001=1、010=2、011=3、100=4、101=5、110=6、111=7)。例如,二进制110101分组为110 101,转换为八进制65。

什么是八进制数字系统?

八进制数字系统(基数8)使用八个数字:0到7。每个数字位置代表8的幂次,类似于十进制位置代表10的幂次。八进制在计算历史上很流行,因为早期计算机使用12位、24位或36位的字,都能被3位整除。它仍然用于Unix/Linux文件权限和某些编程场景。

为什么二进制数字以三个为一组转换为八进制?

二进制数字以三个为一组是因为2³=8,意味着三个二进制位可以精确表示与一个八进制数字(0-7)相同的值范围。这种数学关系使得二进制和八进制之间的转换成为简单的模式匹配。每组三位直接映射到一个八进制数字,无需复杂的算术,使转换快速且无误。

111在八进制中是什么?

二进制111等于八进制7。计算过程为:(1×2²) + (1×2¹) + (1×2⁰) = 4 + 2 + 1 = 7。这是最大的单个八进制数字,因为111是最大的3位二进制数。超过三位的二进制数需要多个八进制数字。例如,二进制1111分组为001 111,转换为八进制17。

八进制在计算中用于哪些场景?

八进制最常用于Unix/Linux文件权限,其中所有者、组和其他人的权限各用3位值表示(读=4、写=2、执行=1)。例如,chmod 755设置为rwxr-xr-x。八进制也在某些编程语言中用作数字字面量前缀(如Python中的0o755、C中的0755),以及历史上在PDP微型计算机和早期大型机中使用。

如何将八进制转换回二进制?

用每个八进制数字对应的3位二进制来替换。映射关系为:0=000、1=001、2=010、3=011、4=100、5=101、6=110、7=111。例如,八进制347转换时将3替换为011、4替换为100、7替换为111,得到011100111。可以去掉前导零得到11100111。这种直接替换有效是因为每个八进制数字完美地代表三个二进制位。

八进制和十六进制有什么区别?

八进制(基数8)将二进制数字分成三组,使用0-7的数字;十六进制(基数16)将二进制数字分成四组,使用0-9加A-F。十六进制在现代计算中更常见,因为大多数系统使用8位字节、16位、32位或64位字,都能被4位整除。八进制在字长能被3整除的旧系统中更为流行。

不分组也能将二进制转换为八进制吗?

可以,您可以先将二进制转换为十进制,然后反复将十进制除以8,记录余数,从而将二进制转换为八进制。但3位分组方法要快得多且不易出错。例如,通过十进制转换110101:(1×32)+(1×16)+(0×8)+(1×4)+(0×2)+(1×1)=53,然后53/8=6余5,得到八进制65。用分组方法:110 101 = 6 5 = 65。分组方法无需任何运算,是二进制转八进制的首选方法。

How to Convert Binary to Octal

Converting binary to octal is one of the simplest number base conversions because octal is base-8 and binary is base-2, and 8 is a perfect power of 2 (23=82^3 = 8). This means every single octal digit maps directly to exactly 3 binary bits. No complex arithmetic is needed — just group and substitute.

Step-by-Step 3-Bit Grouping Method

Follow these steps to convert any binary number (bin) to octal (oct) by hand:

Step 1: Write down the binary number

Start with your binary number. For example, 1101011.

Step 2: Group digits into sets of three from the right

Split the binary number into groups of 3 bits, starting from the rightmost digit. Pad the leftmost group with leading zeros if needed: 001 | 101 | 011.

Step 3: Convert each 3-bit group to its octal digit

Use the mapping: 000=0, 001=1, 010=2, 011=3, 100=4, 101=5, 110=6, 111=7. So 001=1, 101=5, 011=3.

Step 4: Combine the octal digits

Read the octal digits from left to right: 11010112=15381101011_2 = 153_8

Why Each Octal Digit Equals 3 Binary Bits

The mathematical basis for the binary in octal conversion is straightforward: a single octal digit represents values from 0 to 7, which is exactly the range of 3 binary bits (23=82^3 = 8). This means:

(d)8=(b2b1b0)2where d{0,1,...,7}(d)_{8} = (b_2 b_1 b_0)_2 \quad \text{where } d \in \{0,1,...,7\}

Each octal digit dd maps to exactly one 3-bit binary group. This perfect power-of-2 relationship makes the bin to oct conversion a simple mechanical substitution with no division or multiplication required.

Binary to Octal Conversion Table

This is the essential quick-reference table for binary to octal conversion. Each 3-bit binary group maps to exactly one octal digit:

Binary (3 bits)OctalCalculation
00000×4+0×2+0×1=00 \times 4 + 0 \times 2 + 0 \times 1 = 0
00110×4+0×2+1×1=10 \times 4 + 0 \times 2 + 1 \times 1 = 1
01020×4+1×2+0×1=20 \times 4 + 1 \times 2 + 0 \times 1 = 2
01130×4+1×2+1×1=30 \times 4 + 1 \times 2 + 1 \times 1 = 3
10041×4+0×2+0×1=41 \times 4 + 0 \times 2 + 0 \times 1 = 4
10151×4+0×2+1×1=51 \times 4 + 0 \times 2 + 1 \times 1 = 5
11061×4+1×2+0×1=61 \times 4 + 1 \times 2 + 0 \times 1 = 6
11171×4+1×2+1×1=71 \times 4 + 1 \times 2 + 1 \times 1 = 7

This table covers all 256 values from decimal 0 to 255 with their binary and octal equivalents. For values beyond 255, apply the same 3-bit grouping method to convert any binary number to octal.

Binary to Octal Conversion Examples

Below are worked examples showing the bin to oct conversion process step by step, from simple values to multi-digit numbers.

Convert 1101011 to Octal

Binary input: 1101011

1. Group into threes from right: 001 | 101 | 011

2. Convert each group:

  • 0012=18001_2 = 1_8
  • 1012=58101_2 = 5_8
  • 0112=38011_2 = 3_8

3. Result: 11010112=15381101011_2 = 153_8

Decimal equivalent: 107

Convert 11111111 to Octal (255 in decimal)

Binary input: 11111111

1. Group into threes from right: 011 | 111 | 111

2. Convert each group:

  • 0112=38011_2 = 3_8
  • 1112=78111_2 = 7_8
  • 1112=78111_2 = 7_8

3. Result: 111111112=377811111111_2 = 377_8

Decimal equivalent: 255 — the maximum value of an unsigned 8-bit byte.

Convert 111101101 to Octal (Unix Permission Example)

Binary input: 111101101 (rwxr-xr-x)

1. Group into threes from right: 111 | 101 | 101

2. Convert each group:

  • 1112=78111_2 = 7_8 (owner: rwx)
  • 1012=58101_2 = 5_8 (group: r-x)
  • 1012=58101_2 = 5_8 (others: r-x)

3. Result: 1111011012=7558111101101_2 = 755_8

This is the familiar chmod 755 Unix permission — a practical example of how binary to octal conversion is used in real computing.

Binary to Octal in Programming

Most programming languages provide built-in functions for converting between binary and octal. Here are examples in the three most popular languages.

Python

# Convert binary string to octal string
binary_value = "1101011"
octal_value = oct(int(binary_value, 2))
print(octal_value)           # '0o153'

# Remove '0o' prefix
octal_clean = oct(int(binary_value, 2))[2:]
print(octal_clean)           # '153'

# One-liner bin to oct conversion
print(oct(int("11111111", 2))[2:])  # '377'

JavaScript

// Convert binary string to octal string
const binaryValue = "1101011";
const octalValue = parseInt(binaryValue, 2).toString(8);
console.log(octalValue);     // '153'

// For large binary values, use BigInt
const bigBin = "111101101";
const bigOct = BigInt("0b" + bigBin).toString(8);
console.log(bigOct);         // '755'

C

#include <stdio.h>
#include <stdlib.h>

int main() {
    // Convert binary string to decimal, then print as octal
    char *binary = "1101011";
    long decimal = strtol(binary, NULL, 2);
    printf("%lo\n", decimal);  // prints: 153

    // Using octal literals directly in C
    int perms = 0755;  // octal literal
    printf("%o\n", perms);     // prints: 755
    return 0;
}

Key Features

  • Instant binary to octal conversion with real-time validation
  • 3-bit grouping visualization showing the complete bin to oct conversion process
  • Smart input validation for binary numbers (accepts only 0s and 1s)
  • Automatic zero-padding for incomplete leftmost groups
  • Support for converting any length of binary numbers to octal
  • Simultaneous display of octal and decimal equivalents
  • Step-by-step binary to octal conversion breakdown
  • One-click copy for quick transfer of octal results

Applications of Binary to Octal Conversion

  • Unix/Linux file permissions — chmod uses octal to represent read (4), write (2), and execute (1) permission bits
  • Compact binary representation — octal provides a shorter way to express long binary numbers
  • Digital circuit design and analysis requiring binary to octal conversions
  • Assembly language programming and machine code analysis on legacy systems
  • Computer science education for understanding number system relationships
  • PDP and mainframe programming where octal notation is traditional

Related Converters

Explore our other number system and encoding converters for related tasks: