{"id":7219,"date":"2025-11-01T00:10:00","date_gmt":"2025-11-01T07:10:00","guid":{"rendered":"https:\/\/c-for-dummies.com\/blog\/?p=7219"},"modified":"2025-11-08T09:58:08","modified_gmt":"2025-11-08T17:58:08","slug":"todays-date-is-binary","status":"publish","type":"post","link":"https:\/\/c-for-dummies.com\/blog\/?p=7219","title":{"rendered":"Today&#8217;s Date is Binary!"},"content":{"rendered":"<p>You know you&#8217;re a nerd when you look at today&#8217;s date, November 1st, as 11-01 and then you think, &#8220;That&#8217;s a binary number!&#8221; Yeah, nerd.<br \/>\n<!--more--><br \/>\nWhen thinking of a topic for today&#8217;s Lesson, I kept fixating on the date. It got me thinking about how many other dates through the year &mdash; month\/date combinations &mdash; are binary in nature, using only the digits one and zero?<\/p>\n<p>If this were a trivia question during a pub quiz, I&#8217;d riffle though my brain to come up with a quick answer. (And if you&#8217;re a nerd, you&#8217;ve probably already done so.) But instead, and seeing how this post is supposed to be about C programming, I thought I&#8217;d write code that would find all the annual binary dates and output the entire list.<\/p>\n<p>This first part of this code is presented below. It&#8217;s a program that churns through the months and days of the year, outputting each as a two-digit value. After all, if you&#8217;re going to hunt for those binary dates, you must generate the full field in which to search. Consider this code an initial step.<\/p>\n<h3><a href=\"https:\/\/github.com\/dangookin\/C-For-Dummies-Blog\/blob\/master\/2025_11_01-Lesson.c\" rel=\"noopener\" target=\"_blank\">2025_11_01-Lesson.c<\/a><\/h3>\n<pre class=\"screen\">\r\n#include &lt;stdio.h&gt;\r\n\r\nint main()\r\n{\r\n    int month,d;\r\n    int days[12] = {\r\n        31, 28, 31, 30, 31, 30,\r\n        31, 31, 30, 31, 30, 31\r\n    };\r\n\r\n    for( month=0; month&lt;12; month++ )\r\n    {\r\n        for( d=0; d&lt;days[month]; d++ )\r\n            printf(\"%02d%02d\\n\",\r\n                    month+1,\r\n                    d+1\r\n                  );\r\n    }\r\n\r\n    return 0;\r\n}<\/pre>\n<p>Integer variable <code>month<\/code> tracks months of the year; <em>int<\/em> variable <code>d<\/code> tracks the days of a month.<\/p>\n<p>Array <code>days[]<\/code> holds the number of days in each month. Because February 29th isn&#8217;t a binary value, I just omitted it as well as any silly leap year calculations.<\/p>\n<p>Nested <em>for<\/em> loops work through the month and day values. The <em>printf()<\/em> statement outputs the month\/day date as four-digit value. The <code>%02d<\/code> placeholder ensures that output is in the format of a decimal integer, two-digits wide, with a leading zero for single-digit values. The value 1 is added to variables <code>month<\/code> and <code>d<\/code> in the <em>printf()<\/em> statement to make the output human-readable.<\/p>\n<p>Here&#8217;s the output:<\/p>\n<p><code>0101<br \/>\n0102<br \/>\n0103<br \/>\n0104<br \/>\n0105<br \/>\n0106<br \/>\n.<br \/>\n.<br \/>\n.<br \/>\n1227<br \/>\n1228<br \/>\n1229<br \/>\n1230<br \/>\n1231<\/code><\/p>\n<p>That&#8217;s 365 lines of output, each expressing a day of the years as a date two digits wide.<\/p>\n<p>The next phase of the project is to set this output into a form that can be tested for binary values.  I continue this task in <a href=\"https:\/\/c-for-dummies.com\/blog\/?p=7228\">next week&#8217;s Lesson<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Check it out: November 1st is 11-01, which is 13 decimal or 0xD in hex. I&#8217;m a nerd! <a href=\"https:\/\/c-for-dummies.com\/blog\/?p=7219\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-7219","post","type-post","status-publish","format-standard","hentry","category-main"],"_links":{"self":[{"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/7219","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=7219"}],"version-history":[{"count":5,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/7219\/revisions"}],"predecessor-version":[{"id":7244,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/7219\/revisions\/7244"}],"wp:attachment":[{"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=7219"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=7219"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=7219"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}