Buy this tutorial as a PDF for only $5
31 Oct 2018
Halloween
Why is Christmas the same day as Halloween?
Because in Decimal (Dec, also short for December), we count units (ones) on te right hand column, then 10s to the left of that (then hundreds, thousands, etc, as we go further left). But in Octal (Oct, also short for October), we count units (ones) on the right hand column, then 8s, then 64s, 512s, and so on - multiplying by 8, rather than 10, every time.
So in Base 10, Decimal, "25" means "(2 x 10) + (5 x 1)" but in Base 8, Octal, "31" means "(3 x 8) + (1 x 1)".
3 x 8 = 24, and 1 x 1 = 1, so "Oct 31" is "Dec (24+1)" which is "Dec 25"
You can also convert between bases in the Bash shell; if you've declared HALLOWEEN to be a decimal integer (with the "declare -i HALLOWEEN
") command), then "HALLOWEEN=8#31
" won't set it to that literal string, but will instead set it to the value of "31" in Base 8:
$ declare -i HALLOWEEN $ HALLOWEEN=8#31 $ echo $HALLOWEEN 25 $
Appreciate this site? Please consider making a donation:
Books and eBooks
My Shell Scripting books, available in Paperback and eBook formats.
![]() Shell Scripting Tutorial is this tutorial, in 88-page Paperback and eBook formats. Convenient to read on the go, and to keep by your desk as an ever-present companion. | ![]() Shell Scripting: Expert Recipes for Linux, Bash and more is my 564-page book on Shell Scripting. The first half explains the features of the shell; the second half has real-world shell scripts, organised by topic, with detailed discussion of each script. |
Contact
You can mail me with this form. If you expect a reply, please ensure that the address you specify is valid. Don't forget to include the simple addition question at the end of the form, to prove that you are a real person!