{"id":178,"date":"2008-10-10T00:01:31","date_gmt":"2008-10-10T07:01:31","guid":{"rendered":"http:\/\/www.wambooli.com\/blog\/?p=178"},"modified":"2012-10-07T11:18:16","modified_gmt":"2012-10-07T18:18:16","slug":"what-is-zero-anyway","status":"publish","type":"post","link":"https:\/\/www.wambooli.com\/blog\/?p=178","title":{"rendered":"What is Zero, Anyway?"},"content":{"rendered":"<p>Oh, the fun folly of the land of mathematical puzzles. I love it. I don&#8217;t consider myself to be good at math, but I enjoy reading books on math, and looking at the various mathematic theories and postulations, such as &pi;, &radic;-1, and <em>e<\/em>. But when it comes to computer programming, a key question deals with the value of zero.<br \/>\n<!--more--><br \/>\nZero is nothing, of course. But in programming zero can mean a bunch of things:<\/p>\n<p><code>0<\/code> is merely a state. It&#8217;s the opposite of <code>1<\/code>, but it&#8217;s not exactly nothing. As such 0 is often taken to mean the value <em>false<\/em> whereas 1 is the value <em>true<\/em>. Zero could also be off and 1 the value on.<\/p>\n<p>What I&#8217;m writing about is binary, or the 1s and 0s that make up all the information stored in a computer. A binary digit, or <em>bit<\/em>, is either <em>1<\/em> or <em>0<\/em>.<\/p>\n<p>When doing math in a computer, of course, zero means zero or nothing. When you subtract 5 from 5, the result is zero according to the computer, a value. The computer doesn&#8217;t do math with only a single bit. It uses bits in groups of 8, 16, 32, or 64. In that case, the value zero is any of the following:<\/p>\n<p><code>0000 0000<\/code><br \/>\n<code>0000 0000 0000 0000<\/code><br \/>\n<code>0000 0000 0000 0000 0000 0000 0000 0000<\/code><br \/>\n<code>0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000<\/code><\/p>\n<p>(Yes there are also 128-bit wide values, but you get the point.)<\/p>\n<p>Zero is also a character. The ASCII character codes are defined as zero through 127. As such the zero character is defined as the <em>null<\/em>, or empty character. That&#8217;s not the same thing as the space character, which is given code 32. In man programming languages, such as C, character code zero is used to mark the end of chunk of text.<\/p>\n<p>Chunks of text are called <em>strings<\/em>. So, technically, character code zero is the <em>string termination character<\/em>.<\/p>\n<p>Because zero is the value of the null character, some beginning programmers confuse the concept of <em>NULL<\/em> with the null character, or even with the value zero. They&#8217;re not the same things.<\/p>\n<p>NULL is used in programming to represent an empty value, like a house with no one inside. So, for example, say there is an integer variable that can store only values from -32,768 up to 32,767. (Integers are whole numbers, no fractions.) If the variable stores the value zero, then the variable&#8217;s value is zero. But if the variable&#8217;s value is NULL, then the variable exists but doesn&#8217;t really contain any value.<\/p>\n<p>Sure, a NULL variable could be zero. But the idea is that the value is &#8220;undefined.&#8221; Therefore if you assume that it&#8217;s zero, you make a big programmer boo-boo. You might be right, but you&#8217;re probably wrong. Either way, you would be misusing the NULL idea. That&#8217;s because you call kinds of variables can have NULL values, including those that store text, complex database information, even files on disk. Those things can&#8217;t be zero, but they can be NULL.<\/p>\n<p>Confusing? You bet! That&#8217;s why I wrote my programming books. Pick up a copy of <a href=\"http:\/\/www.c-for-dummies.com\/\"><em>C For Dummies<\/em><\/a> if you want to learn more.<\/p>\n<p>Oh, and one other thing that I learned from those math books: The value zero has been proven to not be the same as the value of infinity. Sorry to dash your hopes!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Oh, the fun folly of the land of mathematical puzzles. I love it. I don&#8217;t consider myself to be good at math, but I enjoy reading books on math, and looking at the various mathematic theories and postulations, such as &pi;, &radic;-1, and e. But when it comes to computer programming, a key question deals [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[14],"class_list":["post-178","post","type-post","status-publish","format-standard","hentry","category-main","tag-programming"],"_links":{"self":[{"href":"https:\/\/www.wambooli.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/178","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wambooli.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wambooli.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wambooli.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wambooli.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=178"}],"version-history":[{"count":1,"href":"https:\/\/www.wambooli.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/178\/revisions"}],"predecessor-version":[{"id":3461,"href":"https:\/\/www.wambooli.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/178\/revisions\/3461"}],"wp:attachment":[{"href":"https:\/\/www.wambooli.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=178"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wambooli.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=178"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wambooli.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=178"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}