# What is this numeral system notation?

I used Google search to convert numbers from one numeral system to another.

• 10 to binary is 0b1010;
• 10 to hexadecimal is 0xA.

What's the meaning of 'b' and 'x', accordingly? I think these are abbrevations from binary and hexadecimal. I understand the way converting works. I thought 10 to binary is 1010 and A to hexadecimal. Maybe some scientific notation or something?

• Originally there was just 0x or hexadecimal. 0b was adopted later as an analogy. There is no equivalent for octal because octal has no application in modern computers where everything is arranged in bytes and multiples of bytes. Mainframes still use words that are multiples of 3 bits for which it makes sense to use octal numbers but that is really something of the past (would this be enough of a trigger for mainframe operators to step in and lay out the virtues of octal numbers?). Aug 9, 2021 at 6:31
• Aug 9, 2021 at 6:32

The 0 prefix is a common usage in programming languages to tell that a number will follow and not a symbol. Then, b means binary and x means hexadecimal.

In some programming languages, the leading 0 prefix followed by decimal digits will be understood as an octal number (digits should be between 0 and 7). Demo

If you see `1010` written without any qualification, you don't know if that's:

• Decimal 10 written in base 2 (binary)
• Decimal 30 written in base 3 (ternary)
• Decimal 68 written in base 4 (quarternary)
• [...]
• Decimal 1010 written in base 10 (decimal!)
• Decimal 1452 written in base 11
• [...]
• Decimal 4112 written in base 16 (hexadecimal)
• [...]
• Decimal 1000100 written in base 100

or any one of an infinite number of other possibilities for which base its written in. `0b` and `0x` are just how programmers sometimes indicate a number is written in binary or hexadecimal to avoid this confusion.

As Christophe correctly points out, "a leading zero" – which is a thing never used in ordinary "human" notation of a number – is very often used as an indication.

In my experience, if the next character is a letter, it indicates that the remaining characters are `b`inary or he`x`adecimal. *("Base 2" or "Base 16.") And, if it is a digit, the entire value is "octal" – base 8.

If "binary," each digit represents one bit. If "hexadecimal," each digit/letter represents four. If "octal," three.