A palindromic number, or number palindrome, is a number like 74347, which is the same written forward and backward.
A number can be palindromic in any base, not just decimal. For example, 101101 is a palindrome in binary. A number can also be palindromic in more than one base, like decimal 719848917, which is 101010111010000000010111010101 in binary and 5272002725 in octal.
An efficient way to find palindromes in a single base is to generate them, iterating through each integer and constructing palindromes from them. An efficient way to find numbers that are palindromic in multiple bases is to take a palindrome in one base and test if it’s a palindrome in one or more additional bases.
In this article, I’ll show you C code I wrote that finds multi-base numeric palindromes. I used this code to generate tables of numbers that are palindromic in decimal and binary, decimal and hexadecimal, and decimal and octal. I also used this code to solve Euler problem 36, which asks for the sum of all numbers, less than one million, that are palindromic in decimal and binary.
Continue reading …
PARI/GP is an open source computer algebra system I use frequently in my study of binary numbers. It doesn’t manipulate binary numbers directly — input, and most output, is in decimal — so I use it mainly to do the next best thing: calculate with powers of two. Calculations with powers of two are, indirectly, calculations with binary numbers.
PARI/GP is a sophisticated tool, with several components — yet it’s easy to install and use. I use its command shell in particular, the PARI/GP calculator, or gp for short. I will show you how to use simple gp commands to explore binary numbers.

PARI/GP Calculator (Sample of Calculations Used to Explore Binary Numbers)
Continue reading …
I discovered a cool property of positive integers of the form 10n-1, that is, integers made up of n digits of 9s: they have binary representations that have exactly n digits of trailing 1s. For example, 9,999,999 in decimal is 100110001001011001111111 in binary.
The property is interesting in and of itself, but what is more interesting is the process I went through to discover it. It’s a small-scale example of experimental mathematics: I observed something interesting, experimented to collect more data, developed a hypothesis, and constructed a proof.
Continue reading …
Wolfram Alpha can do many types of calculations, including conversions between numbers in different bases. I’ll demonstrate by showing examples of decimal to binary and binary to decimal conversion.
Continue reading …
I introduced my mother to binary numbers a few weeks ago when I showed her my One Hundred Cheerios in Binary poster. It shows the decimal number 100 in binary — 1100100. She’s not an engineer but she’s good with numbers, so I knew she would get it — if only I could find the right way to explain it. Two days ago, I found the right way.
Continue reading …
If you want to print a floating-point number in binary using C code, you can’t use printf() — it has no format specifier for it. That’s why I wrote a program to do it, a program I describe in this article.
(If you’re wondering why you’d want to print a floating-point number in binary, I’ll tell you that too.)
Continue reading …
PHP has a component called BCMath which does arbitrary-precision, decimal arithmetic. I used BCMath in my decimal/binary converter because:
- Arbitrary-precision lets it operate on very large and very small numbers, numbers that can’t be represented in standard computer word sizes.
- Decimal arithmetic lets it use the same algorithms I’d use to convert between decimal and binary by hand.
(If you’ve written a conversion routine in standard code, especially one to convert decimal fractions to binary, you’ll see the advantage of the second point.)
This article describes the implementation of my conversion routines with BCMath.
Continue reading …
The PHP programming language has many built-in functions for converting numbers from one base to another. In fact, it has so many functions that it can be hard to know which to use. Some functions have similar capabilities, and some work with parameters of different types. We’ll sort through the differences in this article, and explain the proper context in which to use each function.
Continue reading …
The Pioneer 10 (also known as Pioneer F) spacecraft, launched in 1972 and now on a very long journey towards Taurus, has a plaque mounted on it which is designed to inform alien civilizations about the spacecraft’s origin. The plaque contains a diagram of our solar system, the trajectory of the spacecraft, a drawing of a man and woman, and groups of vertical and horizontal strokes — you guessed it, binary code — that gives information about how to find us:

Pioneer 10 Plaque (click image for higher resolution).
Continue reading …
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.
Continue reading …
My son had to do a project for his 100th day of first grade. Since I’ve been teaching him binary — he knows the powers of two from 1 to 512 — we decided to incorporate it into his project. His assignment was to assemble 100 objects in a creative way. This is as creative as I get:

One Hundred Cheerios®, in Binary.
Continue reading …
Do you have twelve coins handy? You can lay them out on a piece of cardboard to keep track of the month, day, and day of the week, as shown here at Evil Mad Scientist Laboratories. Here’s the one I made:

Thursday, January 1st, in pennies.
Continue reading …