Base Conversion In PHP Using Built-In Functions

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 “Base Conversion In PHP Using Built-In Functions”

Binary Code on the Pioneer 10 Spacecraft

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 F Plaque Symbology thumbnail
Pioneer 10 Plaque (click image for higher resolution).

Continue reading “Binary Code on the Pioneer 10 Spacecraft”

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.

Continue reading “Google is a Binary, Hex, and Octal Number Calculator”

One Hundred Cheerios in Binary

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.
One Hundred Cheerios®, in Binary.

Continue reading “One Hundred Cheerios in Binary”

The Binary Marble Adding Machine

The Binary Marble Adding Machine is a device that adds binary numbers mechanically. It uses wood instead of silicon, gravity instead of voltage, and marbles instead of current. We don’t need no stinkin’ CMOS!

The machine may be more cool than practical, but it certainly is educational. It illustrates basic principles of binary numbers, binary arithmetic, and binary logic. Let’s take a closer look.

Continue reading “The Binary Marble Adding Machine”

How to Read a Binary Clock

What is a binary clock? Before doing a web search I would have guessed this:

My Fake Binary Alarm Clock (time is 6:43 PM).
6:43 PM on my fake binary alarm clock (courtesy photo-editing software).

In other words, a regular digital clock, except with binary numerals instead of decimal numerals. But as far as I know, a clock like this doesn’t exist. If you search for “binary clock,” you get a clock of a different design, one like this:

Continue reading “How to Read a Binary Clock”