japhy
Enthusiast
Jan 15, 2001, 5:41 PM
Post #2 of 6
(497 views)

The number system we use is decimal  deci meaning "ten", the number of digits we use (0 through 9). A number like 149 is the same as (1 * 10^2) + (4 * 10^1) + (9 * 10^0), or (1 * 100) + (4 * 10) + (9 * 1), which is 100 + 40 + 9. Octal has eight digits, 0 through 7. Perl distinguishes octal numbers from decimal numbers by starting them with a 0. The number 22 is decimal to Perl, but the number 0225 is octal to Perl, and its equivalent in decimal is (2 * 8^2) + (2 * 8^1) + (5 * 8^0), or (2 * 64) + (2 * 8) + (5 * 1), which is 128 + 16 + 5, or 149. Hexadecimal has 16 digits, 0 through 9, and then 'A' through 'F', which represent the decimal values 10 through 15. Perl represents these numbers with a leading 0x. The number 95 is decimal to Perl, but the number 0x95 is hexadecimal, and its equivalent in decimal is (9 * 16^1) + (5 * 16^0), or (9 * 16) + (5 * 1), which is 144 + 5, or 149. Jeff "japhy" Pinyan  accomplished hacker, teacher, lecturer, and author
