Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Binary Numbers and Representation of Bases

So, binary is just base 2, right? 1s and 0s. But why, when you convert from dec to bin, on Google for example, does it also have an (x)b in front of the actual number? What does the, for example, 0b __ mean?

like image 740
Aristides Avatar asked Jul 08 '13 20:07

Aristides


People also ask

What are binary number bases?

binary number system, in mathematics, positional numeral system employing 2 as the base and so requiring only two different symbols for its digits, 0 and 1, instead of the usual 10 different symbols needed in the decimal system.

What is binary representation of a number?

A binary number is a number expressed in the base-2 numeral system or binary numeral system, a method of mathematical expression which uses only two symbols: typically "0" (zero) and "1" (one).

How do you represent a base?

Base b representation is a way to write numbers using the digits {0, 1, …, (b − 1)}. Common bases: you use base 10 (decimal) every day (digits are {0, 1, . . . , 9}) base 2 (binary) uses digits {0, 1}.

Is binary base-2 or base 10?

While people typically work with numbers using the base 10 (decimal) numeral system, other systems are relevant in computer science, including binary (base 2) and hexadecimal (base 16). Computers manage data packed as sequences of bits (binary digits), which are all zeros or ones.


1 Answers

The notation 0b in front of a number is just an indicator that what follows is represented in binary. That way, if you see something like 1001, you know it's the number "one thousand one" rather than nine written out in binary.

More generally, the prefix 0b usually means "binary," the prefix 0 usually means "octal," and the prefix 0x usually means "hexadecimal."

Hope this helps!

like image 80
templatetypedef Avatar answered Oct 15 '22 23:10

templatetypedef