Binary, Quaternary, Octal, Hexadecimal Simulation

written by Teresa Carrigan


Run model in your browser


Top

WHAT IS IT?

This model demonstrates conversion between any two of the following number bases: two, four, eight, sixteen.

Top

HOW IT WORKS

Any number that is a base which is a power of two can be converted directly to binary, with each digit becoming the same number of bits as the power of two of the base. For example, eight is two cubed, so to convert a number from base eight to base two, each base eight digit is converted directly to three binary bits. The same trick can be used in reverse when starting with base two: group bits from the right into sets of the correct number of bits, then convert each set to a digit in the new base. To convert between bases four, eight, and sixteen, we simply convert to binary first.

This same trick works with any pair of bases that are powers of the same number. It does NOT work in converting between decimal and other bases, unless the other base is 100, 1000, etc.


Home

Applets on this website were written by Teresa Carrigan in 2004, for use in computer science courses at Blackburn College, with the exception of the Fireworks applet. The applets made with NetLogo require Java 1.4.1 or higher to run. The applets made with NetBeans require Java 1.4.2 or higher to run. Applets might not run on Windows 95 or Mac OS 8 or 9. You may obtain the latest Java plugin from Sun's Java site.