Google is a Binary, Hex, and Octal Number Calculator

Did you know you can use Google as a calculator? Type 1 + 2 + 4 + 8 + 16 + 32 into Google’s search box and you’ll get 63 as the result.

Did you know you can use the calculator with numbers in different bases? It can convert numbers between decimal, binary, hexadecimal, and octal, as well as do arithmetic in those bases. To work in a non-decimal base, just prefix numbers as follows: 0b for binary, for example, 0b1010; 0x for hexadecimal, for example, 0xFF; and 0o for octal, for example, 0o701.

Base Conversion

To convert a decimal, hexadecimal, or octal number to binary, type the number followed by the words to binary. Here are some examples (for any example in this article, you can either type it into Google directly or click on its link to have it done for you):

Conversion to Binary
Expression Result
2009 to binary 0b11111011001
0x07D9 to binary 0b11111011001
0o3731 to binary 0b11111011001

To convert a decimal, binary, or octal number to hexadecimal, type the number followed by the words to hex. Here are some examples:

Conversion to Hexadecimal
Expression Result
2009 to hex 0x7D9
0b11111011001 to hex 0x7D9
0o3731 to hex 0x7D9

To convert a decimal, binary, or hexadecimal number to octal, type the number followed by the words to octal. Here are some examples:

Conversion to Octal
Expression Result
2009 to octal 0o3731
0b11111011001 to octal 0o3731
0x07D9 to octal 0o3731

To convert a binary, hexadecimal, or octal number to decimal, type the number followed by the words to decimal. Here are some examples:

Conversion to Decimal
Expression Result
0b11111011001 to decimal 2009
0x07D9 to decimal 2009
0o3731 to decimal 2009

Arithmetic in Other Bases

Here are some examples of arithmetic in other bases:

Arithmetic in Other Bases
Expression Result
0b1010 + 0b1011 0b10101
0xA * 0xF 0x96
0o24 / 0o12 0o2

You can perform arithmetic in one base and have the answer converted to a different base. For example:

Arithmetic in Other Bases With Converted Result
Expression Result
0b1010 + 0b1011 to decimal 21
0xA * 0xF to binary 0b10010110
0o24 / 0o12 to hex 0x2
2^10 + 2^8 + 2^1 to binary 0b10100000010

You can write expressions that include numbers in more than one base. The answer is given in the base of the first operand. For example:

Arithmetic With Mixed Bases
Expression Result
0xF0 + 0b1111 0xFF
0b1111 + 0xF0 0b11111111
15 + 0xF0 255

Powers and Logarithms

You can work with other bases indirectly by working with the decimal equivalent of numbers in those bases. To this end, the ability to compute powers and logarithms is useful. Here are some examples:

Computing Powers and Logarithms
Expression Result Notes
2^32 4 294 967 296 Positive power of two
2^-6 0.015625 Negative power of two
1/2^6 0.015625 Negative power of two
(2^2)^3 64 Composed power of two
8^7 2 097 152 Power of eight
7*16^2 + 13*16 + 9 2 009 Convert 0x7D9 to decimal by hand
lg(256)/lg(16) 2 Change of base computes log16(256) = 2
15/2^6 0.234375 Dyadic fraction
lg(65536) 16 log2(216) = 16
log(2^32) 9.63295986 232 is 10 digits long in base 10

Notes and Limitations

  • For base conversion, you can use the word “in” instead of “to”.
  • For non-decimal bases, the calculator only works with integers.
  • Precision is limited. For example, the largest power of two the calculator can print is 242, and the smallest power of two it can print is 2-12.
  • If the numbers get too large or the calculator doesn’t recognize something in the expression, Google will think it’s a regular query and return search results.

(If you want to convert large integers or decimal fractions to and from binary, check out my Decimal/Binary Converter.)

Dingbat

4 comments

  1. Put “0x1249ad26ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff in decimal” into Google’s search engine and it will calculate it to 10E100 (without even having to submit it). This is, incidentally, the number “google”.

  2. Cool.

    (For some reason the ‘x’ in your comment comes out in a different font and doesn’t give the desired result if copied and pasted into Google. You can make it work though by deleting and retyping the x.)

Comments are closed.

Copyright © 2008-2024 Exploring Binary

Privacy policy

Powered by WordPress

css.php