Thu 20 June 2013

Decimal, Binary, and Hexadecimal Odometers

Posted by Al Sweigart in misc   

It can be difficult to see how other number systems (such as binary and hexadecimal) work since they have a different amount of numerals than the ten numerals of decimal. But imagine that you are counting in these number systems using an old-fashioned analog odometer that has a different amount of numerals for each digit.

The following three odometers always show the same number, but they are written out differently in different number systems:

Decimal (Base-10: 0123456789)

Binary (Base-2: 01)

Hexadecimal (Base-16: 0123456789ABCDEF)



Source code for Gavin Brock's JavaScript odometers. Source code for this binary/decimal/hexadecimal demo all on a single page.



Check out other books by Al Sweigart, free online or available for purchase:

...and other books as well! Or register for the online video course. You can also donate to or support the author directly.