How to use the BIN2OCT function
The BIN2OCT function converts a binary number to octal.
What is the binary system?
The binary system is a positional numeral system that uses only two digits: 0 and 1. The binary system is important in our society, many devices like computers, digital cameras, mobile phones and modern cars use binary code to store, process and communicate data. The binary numeral system makes it easy to store and transmit data using binary digits or bits.
What is a bit?
A bit is a binary digit. It is the most basic unit of information in binary communication and computing. The bit can either be the value 0 (zero) or 1, a bit can also be part of a larger sequence of bits that can represent numbers, characters, and other types of data.
The following table shows the binary, decimal and octal values from 0 (zero) to 17.
Binary | Decimal | Octal |
00000000 | 0 | 0 |
00000001 | 1 | 1 |
00000010 | 2 | 2 |
00000011 | 3 | 3 |
00000100 | 4 | 4 |
00000101 | 5 | 5 |
00000110 | 6 | 6 |
00000111 | 7 | 7 |
00001000 | 8 | 10 |
00001001 | 9 | 11 |
00001010 | 10 | 12 |
00001011 | 11 | 13 |
00001100 | 12 | 14 |
00001101 | 13 | 15 |
00001110 | 14 | 16 |
00001111 | 15 | 17 |
00010000 | 16 | 20 |
00010001 | 17 | 21 |
What is the octal system?
The octal system is a number system with a base of 8 that uses the digits 0, 1, 2, 3, 4, 5, 6 and 7. The octal system is often used in electronics because it is easy to perform a conversion between octal and binary numbers.
Table of Contents
1. BIN2OCT function Syntax
BIN2OCT(number,[places])
2. BIN2OCT function Arguments
number | Required. The binary number you want to convert to octal. The sign bit is the most significant bit of number, the following 9 bits are magnitude bits. Negative numbers are represented using two's-complement notation. Maximum binary values are 10 characters. |
[places] | Optional. The number of characters to use. If not entered the minimum number of characters is used. Use this argument to add leading 0 (zeros). |
What is a sign bit?
The sign bit indicates whether a binary number is positive or negative, if the bit is 0 the number is positive, if the bit is 1, the number is negative.
What is a magnitude bit?
The remaining 9 bits are magnitude bits which represents the absolute value of the number. An absolute number is a number without the sign.
What is two's-complement notation?
Two’s-complement notation is used to represent negative numbers, the magnitude bits are changed from 0 to 1 and 1 to 0 and adding 1 to the result. For example:
Decimal number +9 using 10 bits is 0000001001.
Decimal number -9 using 10 bits is 1111110110 + 1 = 1111110111
3. BIN2OCT function example
The image above shows the BIN2OCT function in cells C3, C4, C5, and C6. It calculates the octal values based on the corresponding cells which contain different binary numbers.
Formula in cell C3:
The first cell B3 contains 0000011001 and the BIN2OCT function returns 31 in cell C3, the second cell B4 contains 0000000011 and the BIN2OCT function returns 3.
The third cell B5 contains 0000000100 and the BIN2OCT function returns 4 in cell C3, the fifth cell B6 contains 0011111111 and the BIN2OCT function returns 377.
The next section describes how these values are calculated in detail.
4. How is the BIN2OCT function calculated in detail?
Follow these steps in order to convert from binary to octal:
- Divide the binary number into groups of three bits starting from the rightmost bit.
- Add leading zeros to make it a full group if the leftmost group contains less than three bits.
- Find the corresponding octal digit for each group using this table:
- Write the octal digits in the same order as the binary groups.
Binary | Decimal | Octal |
000 | 0 | 0 |
001 | 1 | 1 |
010 | 2 | 2 |
011 | 3 | 3 |
100 | 4 | 4 |
101 | 5 | 5 |
110 | 6 | 6 |
111 | 7 | 7 |
5. BIN2OCT function not working
BIN2OCT returns the #NUM! error value if
- more than 10 binary digits are used. See cells B3 and C3 in the image above.
- the number is not a valid binary number. See cells B4 and C4 in the image above.
- [places] is negative. See the formula next to cell C5.
- it requires more than the specified places characters. See the formula next to cell C6.
BIN2OCT returns the #VALUE! error value if places is not a number. See the formula next to cell C7.
The second argument [places]is truncated if it is not an integer. For example, [places] is 4.5 and the BIN2OCT function truncates it to 4. See the formula next to cell C8.
BIN2OCT ignores places and returns a 10-character hexadecimal number if the binary number is negative.
Useful links
BIN2OCT function - Microsoft
Octal numeral system - Wikipedia
Octal Number System - Meaning, Conversion, Solved Examples, Practice Questions (cuemath.com)
'' function examples
The following article has a formula that contains the function.
Table of Contents How to use the BIN2DEC function How to use the BIN2HEX function How to use the BIN2OCT […]
Functions in 'Engineering' category
The BIN2OCT function function is one of 42 functions in the 'Engineering' category.
How to comment
How to add a formula to your comment
<code>Insert your formula here.</code>
Convert less than and larger than signs
Use html character entities instead of less than and larger than signs.
< becomes < and > becomes >
How to add VBA code to your comment
[vb 1="vbnet" language=","]
Put your VBA code here.
[/vb]
How to add a picture to your comment:
Upload picture to postimage.org or imgur
Paste image link to your comment.
Contact Oscar
You can contact me through this contact form