Numerical Base Conversions |
A numerical base system, as defined here, will refer to the numerical system used to represent numerical values in general. We are nearly all familiar with the standard base 10 number system used for general every-day counting and computation, but other systems for representing numbers can also be used for certain purposes. For example, binary (base 2), octal (base 8) and hexadecimal (base 16) are commonly used in computer programming. The concept of base conversion is no deep mathematical mystery and is essentially a very simple process, as will be subsequently demonstrated. As you most probably know, our typical every-day numbers are technically called base 10 numbers. This simply means that all of the every-day number values we use are represented in terms of powers of 10. Converting a base 10 integer into base 16 simply means taking the same numerical value and making it up out of multiples of powers of 16 rather than multiples of powers of 10. Any numerical value can be expressed in multiples of powers of any base from 2 and upward. We simply happen to use base 10 numbers for our standard number system. This section will explore the process of general interconversions between various base systems and also provide related PHP programs and source code designed to perform the essential computations. For the work we will be doing here, we will implement the native PHP arbitrary-precision BC (Binary Calculator) arithmetic operations. This way we can handle integer and fractional values extending out to thousands of digits, if necessary, or just for experimental purposes. |
Jay Tanner - 2017 |