<p>Binary math is an imperative to understand automation. 36 years on the job with 14 years on podium. Especially today where the the world is full of assumptions. All new employees I have had could not conceive how the physical inputs and outputs work in relationships to the masterful programming they developed. </p>

CC BY-SA 4.0
2020-03-09T15:01:59.377Z
Welcome to [cseducators.se].  I have a few requests for edits to your answer.  First, what is "on podium"?  Also, could you expand on your second sentence?
Ben I.
CC BY-SA 4.0
2020-03-08T18:06:29.747Z
2020-03-08T18:06:29.747Z
Jerry Kuntz
<p>(I see that a few answers, though not the accepted one, refer to floating point arithmetic.)</p>
<p>I'm probably in the minority that I teach to engineering-type students, so most of my examples are in floating point numbers. And without understanding binary, how are they going to understand that the following happens</p>
<pre><code>5^2 * (1/5 * 1/5) -1 = 1.192093e-07
5^2 * (1/5 * 1/5) -1 = 2.220446e-16
</code></pre>
<p>(for single &amp; double precision respectively) and what this has to do with the fact that single precision has a 23 bit mantissa and double 51?</p>
<p>Ok, I'm not sure that I would bother first-years with this, but second definitely.</p>

CC BY-SA 4.0
2021-12-20T21:50:09.737Z
I think you meant to do `- 1` somewhere.
Michel de Ruiter
CC BY-SA 4.0
2021-12-20T22:56:05.783Z
Oops. Yes. Thanks.
Victor Eijkhout
CC BY-SA 4.0
2021-12-20T18:51:38.823Z
2021-12-20T22:55:39.757Z
2021-12-20T22:55:39.757Z
Victor Eijkhout
<p>Binary is fundamental to programming, but this has a lot more to do with <em>logic</em> than just with data storage.</p>

<p>Computers work on "yes greater than no" or "no greater than yes."  There are only two choices.</p>

<p>Boolean logic has only two truth values, "true" or "false."  Boolean logic is fundamental to computers.</p>

<p>In more advanced CS subjects such as information theory or security, you have such a concept as "bits of entropy."  On a theoretical conceptual level this has nothing to do with data storage or even number systems and has everything to do with actual binary mathematics.</p>

<p>If you do anything with hardware, boolean logic and binary become essentially intertwined and totally indispensable.</p>

<p>Further, if you are typing on a computer or doing <em>anything with text, ever, ever,</em> on computers, you are dealing with character sets.  As a programmer there are <a href="https://www.joelonsoftware.com/2003/10/08/the-absolute-minimum-every-software-developer-absolutely-positively-must-know-about-unicode-and-character-sets-no-excuses/" rel="noreferrer">certain things that you MUST KNOW about character sets</a>.  :)  Understanding those things requires a grasp of using bits and bytes to store data, and how much information can be stored in them (256 distinct bytes), which goes back to information theory.  And also finally comes to data storage.</p>

<p>You can abstract away the hard stuff sometimes, but you're teaching <strong>Computer Scientists.</strong>  Not part-time kiddie hackers who don't know or care how the magic happens.  Do you want them using <a href="https://www.joelonsoftware.com/2001/12/11/back-to-basics/" rel="noreferrer">Shlemiel the painter's algorithm</a> due to their ignorance?</p>

<p>Besides, <a href="https://www.joelonsoftware.com/2002/11/11/the-law-of-leaky-abstractions/" rel="noreferrer">all abstractions are leaky</a>.  And binary isn't even an implementation detail.  It's <em>totally fundamental</em> to understanding computers at <em>any</em> level.</p>

<p>I can't imagine teaching Boolean logic without teaching binary, or teaching binary without teaching Boolean logic.  As for the actual binary place value system, it's really not that hard.  I've taught this stuff successfully to seven year olds.</p>

<p>Hex and octal are less mandatory but provide useful comparison and contrast to help understand the binary place value system itself.</p>

<hr>

<p><strong>tl;dr: Binary is a <em>must learn early</em> in CS and any related subject.</strong></p>

<p>Don't be like the handwriting teacher teaching "traveling ovals" for months and months when his students can't even write their own names.</p>

<p>Let's have some <em>professional</em> computer scientists who know their basics rock solid, please.  :)</p>

CC BY-SA 3.0
2017-06-23T13:14:19.907Z
I feel like the tone here says students will be completely lost without understanding binary, which is hyperbole. It's a pretty easy thing to learn at any point. But I do agree that it's much easier to understand later CS concepts with a good grasp on binary. I recall several projects in C that would have been much easier if I understood bits and bitwise operators and how to use them.
Chris Schneider
CC BY-SA 3.0
2017-06-23T13:24:47.347Z
@ChrisSchneider I'm trying to think of a single CS concept that isn't rooted in or directly related to discrete elements, Boolean logic or binary.  What would you *teach* of CS to students who didn't know these things?  I'm really wondering.
Wildcard
CC BY-SA 3.0
2017-06-23T13:36:03.063Z
Boolean can be understood quite easily without understanding binary or even knowing it exists. True and false are real world concepts not exclusive to CS and kids learn about `>` `<` `==` in 2nd or 3rd grade. I mean, that _is_ still binary, just not taught as a CS concept.
Chris Schneider
CC BY-SA 3.0
2017-06-23T16:47:57.020Z
how do you know OP is teaching computer scientists? It could just be an introductory programming course, in which case I would *not* expect binary to be taught. It's absolutely not required.
user428517
CC BY-SA 3.0
2017-06-24T17:00:03.833Z
Most students taking a computer science degree have zero intention of being a computer scientist. 95+% of them are going to be maintaining poorly written internal apps for some big company.
corsiKa
CC BY-SA 3.0
2017-06-24T20:28:59.243Z
You didn't stress this enough: Learning binary is the most important thing a first-year can learn! Living in a mostly decimal world working with binary numbers is the best way to learn about models, transformation and data representation as such. Even though it's never explicitly communicated this way.
user1129682
CC BY-SA 3.0
2017-07-24T22:21:39.247Z
@corsiKa, does that mean we should pander to that lowest common denominator in our teaching and not even *attempt* to relay any deep understanding?  Interesting view.  Doesn't seem to belong on CS **Educators** SE, though.  It reminds me of the fantasy novel *The Year of the Griffin* by Diana Wynne Jones, which examines the aftereffects of such an approach to teaching magic.  (A great read, BTW.)  :)
Wildcard
CC BY-SA 3.0
2017-06-23T03:57:08.950Z
2017-06-23T03:57:08.950Z
Wildcard
<p>I introduce binary on Day 1 (if not Day 0). However, in my class, <strong>learning binary is not an end in and of itself: it is a means for understanding the fundamental concept of abstraction.</strong></p>

<p>As a teacher of AP CS Principles, I follow the College Board standards for the course. In that sense I have to teach binary, decimal, and hexadecimal, and conversions between and among them. The first "Enduring Understanding" under "Big Idea 2 - Abstraction" focuses on digital representation of data:</p>

<blockquote>
  <p>Students will understand that...</p>
  
  <p><strong>EU 2.1</strong> A variety of abstractions built on binary sequences can be used to represent all digital data.</p>
</blockquote>

<p>Having taught them binary, we can discuss storage limitations of different data types, floating-point imprecision (as Ellen mentioned), use cases for different bases such as octal and hexadecimal, and file signatures, among many other topics. We use <code>xxd</code> to investigate a bitmap (and dive deeper into color representation) and to examine the metadata stored in pictures taken on a cell phone.</p>

<p>Do I think binary-for-binary's sake is worth it? Probably not. It's a lot of work for not a huge pay-off for a beginner programmer, and it's easy enough to look up a binary-decimal converter.</p>

<p>Is it worth it to understand binary in terms of the larger context of abstraction and to be comfortable occasionally looking at and deciphering representations of it (along with octal or hex)? <strong>Absolutely. It's how all digital data is represented, and the groundwork should be there in some form from the start.</strong></p>

CC BY-SA 3.0
2017-06-22T23:34:03.377Z
2017-06-22T23:34:03.377Z
Peter
<p>I see no reason to teach binary in an <em>introductory</em> programming class. It is not generally needed (see exceptions below) when programming in high-level languages, which is usually what is taught to freshmen students. If you have extra time in your course, rather than introducing binary, why not introduce them to other areas of CS that freshmen don't usually see, such as human-computer interaction, algorithms, computing history, Moore's Law, assistive technology, internationalization, etc.</p>

<p>I teach binary when there's a need to: in Computer Architecture, which is a required (2nd- or 3rd-year) course in our undergraduate CS minor and major. It is absolutely necessary in that class, to understand how processors work, how caches work, and how numbers and Unicode characters are represented. I don't teach Computer Networks but could imagine its being taught there.</p>

<p>If a curriculum does not include Computer Architecture, students should still learn enough about binary numbers and floating point encoding so they know why floating-point arithmetic is inexact.</p>

<p>If/when you do teach binary, teach them how to count on their fingers in binary.
<a href="https://i.sstatic.net/mRXBu.jpg" rel="noreferrer"><img src="https://i.sstatic.net/mRXBu.jpg" alt="Illustration of counting in binary on fingers"></a></p>

<p>I give extra credit in Computer Architecture for counting up to 31 on one hand. Just be careful...</p>

<p><a href="https://i.sstatic.net/6HVee.gif" rel="noreferrer"><img src="https://i.sstatic.net/6HVee.gif" alt="Cartoon in which teacher demonstrating binary on his hands is disciplined for giving students the finger"></a></p>

<p>See also <a href="http://www.smbc-comics.com/?id=2807" rel="noreferrer">this cartoon</a>.</p>

CC BY-SA 3.0
2017-06-22T21:58:06.757Z
I always make that joke about 132. :)
Ben I.
CC BY-SA 3.0
2017-06-23T16:51:21.497Z
I'm very careful about that in the HS classroom.
Alfred Thompson
CC BY-SA 3.0
2017-06-23T17:54:33.690Z
Good point, @AlfredThompson. I teach at a women's college, where the students are more mature than high schoolers.
Ellen Spertus
CC BY-SA 3.0
2017-06-24T00:46:13.577Z
This is unwise.  Ironically, the more high-level the language, the more likely the bite of the unanticipated sign bit will be severe.  Good luck to the binary-ignorant Java programmer who needs to place multi-byte values in a stream of data.
Chris Stratton
CC BY-SA 3.0
2017-06-24T00:57:53.743Z
@ChrisStratton Whether programmers should know binary is a different question than whether they should learn it freshman year. Big-O notation is important, but students typically don't learn that until their second year of college CS.
Ellen Spertus
CC BY-SA 3.0
2017-06-24T01:03:51.513Z
Big-O notation is far less important.  First, the notation itself does nothing; it's the concepts it expresses - you can have perfectly fine conversations about efficient computation without involving it at all.  But even then, ignorance of algorithmic efficiency may get you *slow* code; but ignorance of numeric formats yields *broken* code.
Chris Stratton
CC BY-SA 3.0
2017-06-24T17:01:53.837Z
@BenI.the important question is when you sign 132 is that right endian or left endian?
corsiKa
CC BY-SA 3.0
2017-06-25T03:01:50.740Z
The idea that binary "is not needed when programming in high-level languages" is not just utterly wrong but dangerous. It leads to ideas like thinking floating point numbers are real numbers.
R.. GitHub STOP HELPING ICE
CC BY-SA 3.0
2017-06-25T14:04:10.233Z
@R.. Good point. If you read my full answer, you'll see that I mention learning it later in the curriculum, just not in the first year. I'll qualify my second sentence.
Ellen Spertus
CC BY-SA 3.0
2017-06-22T21:18:40.637Z
2017-06-25T14:05:14.867Z
2017-06-25T14:05:14.867Z
Ellen Spertus
<p>When teaching first year CS students, I very briefly touch on Binary -- basically just explaining that 1 means on, 0 means off, and what it means to have a number of base X (i.e. I go over why Decimal numbers work the way they do in relation to Binary).</p>

<p>I think this depends greatly on the curriculum at your institution, but I have never found students to struggle later in their education due to someone skimping on Binary their first year -- as such, I err on the side of letting them explore it deeper in subsequent classes.</p>

CC BY-SA 3.0
2017-06-22T20:33:29.743Z
Nice answer. Welcome to CSE!
Ben I.
CC BY-SA 3.0
2017-06-22T20:36:24.890Z
@BenI. Thanks! Please feel free to let me know if my answer could be improved.
deckeresq
CC BY-SA 3.0
2017-06-23T03:31:05.987Z
Re, "1 means on, 0 means off."  If you're using bits as BInary digiTS, then 1 means 1x2^n where n is the bit position, and 0 means 0.  If you're using them for any other purpose in software, then 1 and 0 mean whatever the developer wants them to mean.  If you're using them to control hardware, then 1 and 0 mean whatever was convenient for the hardware designer.  (Back in the days of TTL logic, 0 often meant "on" and 1 "off".)
Solomon Slow
CC BY-SA 3.0
2017-06-23T13:52:08.067Z
Ah, sorry, my answer isn't completely clear there. I'll figure out how best to update that. Thanks!
deckeresq
CC BY-SA 3.0
2017-06-22T20:13:17.737Z
2017-06-22T20:13:17.737Z
deckeresq
<p>In my experience, kids need a second exposure to binary before it starts to really sink in. During sophomore and junior years, we use binary heavily for certain key moments at my school, so that freshman exposure is absolutely vital.  I still have to present it a second time when they are sophomores, but I can only imagine how much harder all of that material would be without the benefit of covering it the first time.</p>

CC BY-SA 3.0
2017-06-22T22:49:23.217Z
Our first real Computer Science Problem: How do you change base representations of numbers. Here is a big fat place to introduce mod (%).
ncmathsadist
CC BY-SA 3.0
2017-06-22T20:29:12.500Z
2017-06-22T20:29:12.500Z
Ben I.
<blockquote>
<p>Student: My program is adding a list of positive ints in a loop, but the total ends up negative!  What happened?</p>
<p>Teacher: <code>int</code> can only store numbers up to <code>Integer.MAX_VALUE</code>, after which it wraps around to negative values.</p>
<p>Student: Huh?  Why do we call it <code>int</code> then?  That's not how integers work!</p>
<p>Teacher: Uh, well, it's an abstraction, but some abstractions aren't perfect.</p>
<p>Student: [<em>looks up <code>Integer.MAX_VALUE</code></em>...]  Why is the maximum value 2147483647?  That's a pretty arbitrary number.</p>
<p>Teacher: Computers represent integers in binary... [mini-lecture follows]</p>
<p>Student: Okay, fine.  But <code>Integer.MIN_VALUE</code> is -2147483648; why isn't it symmetric?  What happens if we negate <code>Integer.MIN_VALUE</code>, then?</p>
<p>Teacher: [two's complement mini-lecture]</p>
</blockquote>
<hr />
<p>You may or may not want to teach a specific lesson on binary (and octal and hex, and depending on your students, the concept of place value in general), but your students are going to run into leaky abstractions at some point, and you should be prepared to provide just-in-time education.</p>
<p>If you're working in a language with arbitrary-precision integers, you get to delay this line of questioning until your students wonder why addition suddenly gets slower once the values get large enough.  General understanding of how values are physically represented will also help students with questions like &quot;My program runs great on my desktop, but when I tried to run it on a Raspberry Pi, it runs out of memory.  How can I make it use less memory?&quot;</p>

CC BY-SA 3.0
2017-06-23T20:42:50.633Z
Hi Jeffery! Welcome to [cseducators.se]! This is a good answer, and we hope to hear more from you in the future. I like your use of an example conversation.
thesecretmaster
CC BY-SA 3.0
2017-06-23T20:39:08.563Z
2017-06-23T20:39:08.563Z
2020-06-18T08:36:57.023Z
Jeffrey Bosboom
<p>In an Introductory class I would hope to see it at least mentioned. As they get deeper into a CS curriculum then they should become more adept at moving between Binary, Hex and Decimal (as well as Ascii, UTF-8, etc.) so that they have an understanding of how the computer they code for consumes their code.</p>

<p>You'll need to structure it so you don't get too derailed. Binary can be a course unto itself as you shift into math, even Big vs Little endian can cause headaches early on.</p>

<p>You also mentioned "storage". Both Text and "binary files" (think EXE, SO, DLLs etc.) have OS variations that you could look at. Perhaps you meant over the wire; so more XML, JSON, and/or HTTP - all interesting aspects.</p>

<p>I'd advise keeping it on topic, focused, and clearly understandable by your audience.</p>

CC BY-SA 3.0
2017-06-22T19:42:23.013Z
2017-06-22T19:42:23.013Z
AlG
<p>Understanding binary, hex, and octal numbers contributes to insight on the workings of computers, although octal numbers are fading in importance in comparison to hex numbers.  Here are a few reasons</p>

<p>File permissions are managed with octal digits.  The command</p>

<p><code>chmod 644 file.txt</code></p>

<p>uses three octal digits to set the visibility of the file.  (4 read, 2 write, 1 execute so the 6 means read/write for the user and the 4s mean read permission for the group and others)</p>

<p>Colors are represented by hex codes; a color and its transparency are represented in a 32 bit integer (8 bits for red, green, blue, and alpha [transparency]. </p>

<p>Memory addresses are output as hex code. It is indispensable for every beginning programmer to be aware of the meaning of memory addresses.  Note that Python and Java variables are basically..... pointers.</p>

<p>Hex and octal numbers are conveniences for humans because they shorten a number's representation.  Everything stored in the computer and the file system consists of one-dimensional streams of bits.</p>

CC BY-SA 3.0
2017-06-22T21:38:42.720Z
2017-06-22T21:38:42.720Z
ncmathsadist
<p>Binary is ESSENTIAL for designing digital logic, so be sure to include it for students who plan to become electronic engineers working in digital design. </p>

CC BY-SA 3.0
2017-06-22T23:16:37.340Z
Strongly disagree. Digital logic is designed at a higher level of abstraction than this. Yes, eventually the mapping to bits is relevant, but datapath is mostly '+' and '-' functions. Logic, yes. Binary not so much.
Sean Houlihane
CC BY-SA 3.0
2017-06-23T08:44:25.497Z
@SeanHoulihane - boolean logic is literally about binary states.
Davor
CC BY-SA 3.0
2017-06-23T09:03:03.377Z
@Davor yes, as in 2 state logic (or sometimes 4). Nothing to do with power of 2 number systems.
Sean Houlihane
CC BY-SA 3.0
2017-06-22T22:14:52.887Z
2017-06-22T22:14:52.887Z
user6030
<p>I feel it is important to know binary. Some students find it enjoyable (and some might even use it in their projects to encode and decode custom data) and those who don't simply ignore it.</p>

<p>I think it's good to teach it because a) it gives students the notion of how computers actually work (they know it works with electricity, so 0 is low current, 1 is high current) and b) it's useful in coding, as they can use it to serialize data.</p>

<p>Eventually, if there's time, teaching <em>how it can be used</em> is good, and not only <em>what it is</em>.</p>

CC BY-SA 3.0
2017-06-26T00:26:10.303Z
Changing base representations of numbers is an excellent early example of a non-trivial algorithm.
ncmathsadist
CC BY-SA 3.0
2017-06-23T06:10:52.240Z
2017-06-23T06:10:52.240Z
ItamarG3
<p>I teach my freshmen Binary because I'm old school I guess. I do want them to know how data is stored and that means Binary to me. How do others feel? Is it a <em>must learn early</em> or a <em>nice to have if there is room?</em></p>

CC BY-SA 3.0
2017-06-22T19:26:45.810Z
Can you specify your audience? Is this 1st year high school or university? Is the course for Computer Science majors, or everyone?
Kaneki
CC BY-SA 3.0
2017-06-22T23:23:42.667Z
There is a big difference between teaching it, mentioning it in passing or using it as an example when teaching hex. You could just as usefully teach hex as having a 4 bit mapping for each digit, and that would be closer to what designers use most of the time.
Sean Houlihane
CC BY-SA 3.0
2017-06-23T04:26:53.673Z
If you don't understand binary you're going to have a hard time with bitmapped flags--and high level languages do have bitmapped flags.
Loren Pechtel
CC BY-SA 3.0
2017-06-23T06:50:22.940Z
Wait, you mean they haven't been taught number representations in high school? I'm truly shocked.
Jörg W Mittag
CC BY-SA 3.0
2017-06-23T09:51:20.440Z
@LorenPechtel your comment made me realize I haven't manually built a binary bitmapped flag in **years** (actually, since my 2nd college year). Nowadays, most popular functions use constants that you can OR together, e.g. [PHP's json_encode](http://php.net/manual/es/function.json-encode.php). We are so spoiled!
xDaizu
CC BY-SA 3.0
2017-06-23T16:50:35.887Z
I teach high school so was thinking about that. But really the first CS course at any grade level is fairly similar in scope and sequence if you assume not previous knowledge.
Alfred Thompson
CC BY-SA 3.0
2017-06-23T18:37:26.903Z
If you don't teach them binary how are you going to teach them that 5 * 0.2 != 1.0?
davidbak
CC BY-SA 3.0
2017-06-23T22:04:45.757Z
What exactly is "learning Binary"? Knowing that computers work with a binary system, or being able to read and maybe calculate with binary numbers?
Paŭlo Ebermann
CC BY-SA 3.0
2017-06-24T18:29:18.927Z
@JörgWMittag Oddly, very little emphasis is placed on this is math classes in American public schools in my experience. When I entered my first year of college as a Computer Science major, I was shocked by how many of even the best students had no idea what a number base was. After I transferred into public school during high school, each year I ended up teaching fellow students about number bases before mathematics competitions because they weren't taught in any of the classes. And, again, these were the students who were participating in mathematics contests, not just average students.
reirab
CC BY-SA 3.0
2017-06-24T20:48:11.020Z
@JörgWMittag In my experience, grade 6 in a private school is roughly equivalent to grade 12 in a public school.
Kevin Krumwiede
CC BY-SA 3.0
2017-06-25T18:28:51.940Z
The question is, “is it a pre-requisite to teaching another part of the syllabus”
ctrl-alt-delor
CC BY-SA 3.0
2017-06-25T18:30:04.593Z
There are 10 types of people in the world: those that know binary, and those that don't.
ctrl-alt-delor
CC BY-SA 3.0
2017-06-26T00:22:39.727Z
@richard: I can never decide which version of that joke is funnier: the one with 10 or the one with 11.
Jörg W Mittag
<curriculum-design>
How important is learning Binary for first-year college students?
# How important is learning Binary for first-year college students?

(Asked by: username_0 on 2017-06-22)

I teach my freshmen Binary because I'm old school I guess. I do want them to know how data is stored and that means Binary to me. How do others feel? Is it a *must learn early* or a *nice to have if there is room?*

**Tags:** curriculum-design

> **Comments:**
> **username_1**: Can you specify your audience? Is this 1st year high school or university? Is the course for Computer Science majors, or everyone?  
> **username_2**: There is a big difference between teaching it, mentioning it in passing or using it as an example when teaching hex. You could just as usefully teach hex as having a 4 bit mapping for each digit, and that would be closer to what designers use most of the time.  
> **username_3**: If you don't understand binary you're going to have a hard time with bitmapped flags--and high level languages do have bitmapped flags.  
> **username_4**: Wait, you mean they haven't been taught number representations in high school? I'm truly shocked.  
> **username_5**: @LorenPechtel your comment made me realize I haven't manually built a binary bitmapped flag in **years** (actually, since my 2nd college year). Nowadays, most popular functions use constants that you can OR together, e.g. [PHP's json_encode](http://php.net/manual/es/function.json-encode.php). We are so spoiled!  
> **username_0**: I teach high school so was thinking about that. But really the first CS course at any grade level is fairly similar in scope and sequence if you assume not previous knowledge.  
> **username_6**: If you don't teach them binary how are you going to teach them that 5 * 0.2 != 1.0?  
> **username_7**: What exactly is "learning Binary"? Knowing that computers work with a binary system, or being able to read and maybe calculate with binary numbers?  
> **username_8**: @JörgWMittag Oddly, very little emphasis is placed on this is math classes in American public schools in my experience. When I entered my first year of college as a Computer Science major, I was shocked by how many of even the best students had no idea what a number base was. After I transferred into public school during high school, each year I ended up teaching fellow students about number bases before mathematics competitions because they weren't taught in any of the classes. And, again, these were the students who were participating in mathematics contests, not just average students.  
> **username_9**: @JörgWMittag In my experience, grade 6 in a private school is roughly equivalent to grade 12 in a public school.  
> **username_10**: The question is, “is it a pre-requisite to teaching another part of the syllabus”  
> **username_10**: There are 10 types of people in the world: those that know binary, and those that don't.  
> **username_4**: @richard: I can never decide which version of that joke is funnier: the one with 10 or the one with 11.  

---

## 12 answers

### Answer by username_15 on 2017-06-23. Score: 25 | Accepted answer

Binary is fundamental to programming, but this has a lot more to do with *logic* than just with data storage.

Computers work on "yes greater than no" or "no greater than yes." There are only two choices.

Boolean logic has only two truth values, "true" or "false." Boolean logic is fundamental to computers.

In more advanced CS subjects such as information theory or security, you have such a concept as "bits of entropy." On a theoretical conceptual level this has nothing to do with data storage or even number systems and has everything to do with actual binary mathematics.

If you do anything with hardware, boolean logic and binary become essentially intertwined and totally indispensable.

Further, if you are typing on a computer or doing *anything with text, ever, ever,* on computers, you are dealing with character sets. As a programmer there are [certain things that you MUST KNOW about character sets](https://www.joelonsoftware.com/2003/10/08/the-absolute-minimum-every-software-developer-absolutely-positively-must-know-about-unicode-and-character-sets-no-excuses/). :) Understanding those things requires a grasp of using bits and bytes to store data, and how much information can be stored in them (256 distinct bytes), which goes back to information theory. And also finally comes to data storage.

You can abstract away the hard stuff sometimes, but you're teaching **Computer Scientists.** Not part-time kiddie hackers who don't know or care how the magic happens. Do you want them using [Shlemiel the painter's algorithm](https://www.joelonsoftware.com/2001/12/11/back-to-basics/) due to their ignorance?

Besides, [all abstractions are leaky](https://www.joelonsoftware.com/2002/11/11/the-law-of-leaky-abstractions/). And binary isn't even an implementation detail. It's *totally fundamental* to understanding computers at *any* level.

I can't imagine teaching Boolean logic without teaching binary, or teaching binary without teaching Boolean logic. As for the actual binary place value system, it's really not that hard. I've taught this stuff successfully to seven year olds.

Hex and octal are less mandatory but provide useful comparison and contrast to help understand the binary place value system itself.

---

**tl;dr: Binary is a *must learn early* in CS and any related subject.**

Don't be like the handwriting teacher teaching "traveling ovals" for months and months when his students can't even write their own names.

Let's have some *professional* computer scientists who know their basics rock solid, please. :)

> **Comments:**
> **username_16**: I feel like the tone here says students will be completely lost without understanding binary, which is hyperbole. It's a pretty easy thing to learn at any point. But I do agree that it's much easier to understand later CS concepts with a good grasp on binary. I recall several projects in C that would have been much easier if I understood bits and bitwise operators and how to use them.  
> **username_15**: @ChrisSchneider I'm trying to think of a single CS concept that isn't rooted in or directly related to discrete elements, Boolean logic or binary.  What would you *teach* of CS to students who didn't know these things?  I'm really wondering.  
> **username_16**: Boolean can be understood quite easily without understanding binary or even knowing it exists. True and false are real world concepts not exclusive to CS and kids learn about `>` `<` `==` in 2nd or 3rd grade. I mean, that _is_ still binary, just not taught as a CS concept.  
> **username_17**: how do you know OP is teaching computer scientists? It could just be an introductory programming course, in which case I would *not* expect binary to be taught. It's absolutely not required.  
> **username_18**: Most students taking a computer science degree have zero intention of being a computer scientist. 95+% of them are going to be maintaining poorly written internal apps for some big company.  
> **username_19**: You didn't stress this enough: Learning binary is the most important thing a first-year can learn! Living in a mostly decimal world working with binary numbers is the best way to learn about models, transformation and data representation as such. Even though it's never explicitly communicated this way.  
> **username_15**: @username_18, does that mean we should pander to that lowest common denominator in our teaching and not even *attempt* to relay any deep understanding?  Interesting view.  Doesn't seem to belong on CS **Educators** SE, though.  It reminds me of the fantasy novel *The Year of the Griffin* by Diana Wynne Jones, which examines the aftereffects of such an approach to teaching magic.  (A great read, BTW.)  :)  

---

### Answer by username_21 on 2017-06-22. Score: 27

I see no reason to teach binary in an *introductory* programming class. It is not generally needed (see exceptions below) when programming in high-level languages, which is usually what is taught to freshmen students. If you have extra time in your course, rather than introducing binary, why not introduce them to other areas of CS that freshmen don't usually see, such as human-computer interaction, algorithms, computing history, Moore's Law, assistive technology, internationalization, etc.

I teach binary when there's a need to: in Computer Architecture, which is a required (2nd- or 3rd-year) course in our undergraduate CS minor and major. It is absolutely necessary in that class, to understand how processors work, how caches work, and how numbers and Unicode characters are represented. I don't teach Computer Networks but could imagine its being taught there.

If a curriculum does not include Computer Architecture, students should still learn enough about binary numbers and floating point encoding so they know why floating-point arithmetic is inexact.

If/when you do teach binary, teach them how to count on their fingers in binary.
[![Illustration of counting in binary on fingers](https://i.sstatic.net/mRXBu.jpg)](https://i.sstatic.net/mRXBu.jpg)

I give extra credit in Computer Architecture for counting up to 31 on one hand. Just be careful...

[![Cartoon in which teacher demonstrating binary on his hands is disciplined for giving students the finger](https://i.sstatic.net/6HVee.gif)](https://i.sstatic.net/6HVee.gif)

See also [this cartoon](http://www.smbc-comics.com/?id=2807).

> **Comments:**
> **username_12**: I always make that joke about 132. :)  
> **username_0**: I'm very careful about that in the HS classroom.  
> **username_21**: Good point, @AlfredThompson. I teach at a women's college, where the students are more mature than high schoolers.  
> **username_22**: This is unwise.  Ironically, the more high-level the language, the more likely the bite of the unanticipated sign bit will be severe.  Good luck to the binary-ignorant Java programmer who needs to place multi-byte values in a stream of data.  
> **username_21**: @ChrisStratton Whether programmers should know binary is a different question than whether they should learn it freshman year. Big-O notation is important, but students typically don't learn that until their second year of college CS.  
> **username_22**: Big-O notation is far less important.  First, the notation itself does nothing; it's the concepts it expresses - you can have perfectly fine conversations about efficient computation without involving it at all.  But even then, ignorance of algorithmic efficiency may get you *slow* code; but ignorance of numeric formats yields *broken* code.  
> **username_18**: @BenI.the important question is when you sign 132 is that right endian or left endian?  
> **username_23**: The idea that binary "is not needed when programming in high-level languages" is not just utterly wrong but dangerous. It leads to ideas like thinking floating point numbers are real numbers.  
> **username_21**: @R.. Good point. If you read my full answer, you'll see that I mention learning it later in the curriculum, just not in the first year. I'll qualify my second sentence.  

---

### Answer by username_20 on 2017-06-22. Score: 12

I introduce binary on Day 1 (if not Day 0). However, in my class, **learning binary is not an end in and of itself: it is a means for understanding the fundamental concept of abstraction.**

As a teacher of AP CS Principles, I follow the College Board standards for the course. In that sense I have to teach binary, decimal, and hexadecimal, and conversions between and among them. The first "Enduring Understanding" under "Big Idea 2 - Abstraction" focuses on digital representation of data:

> Students will understand that...
>
> **EU 2.1** A variety of abstractions built on binary sequences can be used to represent all digital data.

Having taught them binary, we can discuss storage limitations of different data types, floating-point imprecision (as Ellen mentioned), use cases for different bases such as octal and hexadecimal, and file signatures, among many other topics. We use `xxd` to investigate a bitmap (and dive deeper into color representation) and to examine the metadata stored in pictures taken on a cell phone.

Do I think binary-for-binary's sake is worth it? Probably not. It's a lot of work for not a huge pay-off for a beginner programmer, and it's easy enough to look up a binary-decimal converter.

Is it worth it to understand binary in terms of the larger context of abstraction and to be comfortable occasionally looking at and deciphering representations of it (along with octal or hex)? **Absolutely. It's how all digital data is represented, and the groundwork should be there in some form from the start.**


---

### Answer by username_27 on 2017-06-23. Score: 8

> Student: My program is adding a list of positive ints in a loop, but the total ends up negative! What happened?
>
> Teacher: `int` can only store numbers up to `Integer.MAX_VALUE`, after which it wraps around to negative values.
>
> Student: Huh? Why do we call it `int` then? That's not how integers work!
>
> Teacher: Uh, well, it's an abstraction, but some abstractions aren't perfect.
>
> Student: [*looks up `Integer.MAX_VALUE`*...] Why is the maximum value 2147483647? That's a pretty arbitrary number.
>
> Teacher: Computers represent integers in binary... [mini-lecture follows]
>
> Student: Okay, fine. But `Integer.MIN_VALUE` is -2147483648; why isn't it symmetric? What happens if we negate `Integer.MIN_VALUE`, then?
>
> Teacher: [two's complement mini-lecture]

---

You may or may not want to teach a specific lesson on binary (and octal and hex, and depending on your students, the concept of place value in general), but your students are going to run into leaky abstractions at some point, and you should be prepared to provide just-in-time education.

If you're working in a language with arbitrary-precision integers, you get to delay this line of questioning until your students wonder why addition suddenly gets slower once the values get large enough. General understanding of how values are physically represented will also help students with questions like "My program runs great on my desktop, but when I tried to run it on a Raspberry Pi, it runs out of memory. How can I make it use less memory?"

> **Comments:**
> **username_28**: Hi Jeffery! Welcome to [cseducators.se]! This is a good answer, and we hope to hear more from you in the future. I like your use of an example conversation.  

---

### Answer by username_24 on 2017-06-22. Score: 6

When teaching first year CS students, I very briefly touch on Binary -- basically just explaining that 1 means on, 0 means off, and what it means to have a number of base X (i.e. I go over why Decimal numbers work the way they do in relation to Binary).

I think this depends greatly on the curriculum at your institution, but I have never found students to struggle later in their education due to someone skimping on Binary their first year -- as such, I err on the side of letting them explore it deeper in subsequent classes.

> **Comments:**
> **username_12**: Nice answer. Welcome to CSE!  
> **username_24**: @BenI. Thanks! Please feel free to let me know if my answer could be improved.  
> **username_25**: Re, "1 means on, 0 means off."  If you're using bits as BInary digiTS, then 1 means 1x2^n where n is the bit position, and 0 means 0.  If you're using them for any other purpose in software, then 1 and 0 mean whatever the developer wants them to mean.  If you're using them to control hardware, then 1 and 0 mean whatever was convenient for the hardware designer.  (Back in the days of TTL logic, 0 often meant "on" and 1 "off".)  
> **username_24**: Ah, sorry, my answer isn't completely clear there. I'll figure out how best to update that. Thanks!  

---

### Answer by username_12 on 2017-06-22. Score: 5

In my experience, kids need a second exposure to binary before it starts to really sink in. During sophomore and junior years, we use binary heavily for certain key moments at my school, so that freshman exposure is absolutely vital. I still have to present it a second time when they are sophomores, but I can only imagine how much harder all of that material would be without the benefit of covering it the first time.

> **Comments:**
> **username_26**: Our first real Computer Science Problem: How do you change base representations of numbers. Here is a big fat place to introduce mod (%).  

---

### Answer by username_30 on 2017-06-22. Score: 4

Binary is ESSENTIAL for designing digital logic, so be sure to include it for students who plan to become electronic engineers working in digital design.

> **Comments:**
> **username_2**: Strongly disagree. Digital logic is designed at a higher level of abstraction than this. Yes, eventually the mapping to bits is relevant, but datapath is mostly '+' and '-' functions. Logic, yes. Binary not so much.  
> **username_31**: @SeanHoulihane - boolean logic is literally about binary states.  
> **username_2**: @username_31 yes, as in 2 state logic (or sometimes 4). Nothing to do with power of 2 number systems.  

---

### Answer by username_29 on 2017-06-22. Score: 3

In an Introductory class I would hope to see it at least mentioned. As they get deeper into a CS curriculum then they should become more adept at moving between Binary, Hex and Decimal (as well as Ascii, UTF-8, etc.) so that they have an understanding of how the computer they code for consumes their code.

You'll need to structure it so you don't get too derailed. Binary can be a course unto itself as you shift into math, even Big vs Little endian can cause headaches early on.

You also mentioned "storage". Both Text and "binary files" (think EXE, SO, DLLs etc.) have OS variations that you could look at. Perhaps you meant over the wire; so more XML, JSON, and/or HTTP - all interesting aspects.

I'd advise keeping it on topic, focused, and clearly understandable by your audience.


---

### Answer by username_26 on 2017-06-22. Score: 3

Understanding binary, hex, and octal numbers contributes to insight on the workings of computers, although octal numbers are fading in importance in comparison to hex numbers. Here are a few reasons

File permissions are managed with octal digits. The command

`chmod 644 file.txt`

uses three octal digits to set the visibility of the file. (4 read, 2 write, 1 execute so the 6 means read/write for the user and the 4s mean read permission for the group and others)

Colors are represented by hex codes; a color and its transparency are represented in a 32 bit integer (8 bits for red, green, blue, and alpha [transparency].

Memory addresses are output as hex code. It is indispensable for every beginning programmer to be aware of the meaning of memory addresses. Note that Python and Java variables are basically..... pointers.

Hex and octal numbers are conveniences for humans because they shorten a number's representation. Everything stored in the computer and the file system consists of one-dimensional streams of bits.


---

### Answer by username_32 on 2017-06-23. Score: 2

I feel it is important to know binary. Some students find it enjoyable (and some might even use it in their projects to encode and decode custom data) and those who don't simply ignore it.

I think it's good to teach it because a) it gives students the notion of how computers actually work (they know it works with electricity, so 0 is low current, 1 is high current) and b) it's useful in coding, as they can use it to serialize data.

Eventually, if there's time, teaching *how it can be used* is good, and not only *what it is*.

> **Comments:**
> **username_26**: Changing base representations of numbers is an excellent early example of a non-trivial algorithm.  

---

### Answer by username_13 on 2021-12-20. Score: 1

(I see that a few answers, though not the accepted one, refer to floating point arithmetic.)
I'm probably in the minority that I teach to engineering-type students, so most of my examples are in floating point numbers. And without understanding binary, how are they going to understand that the following happens
5^2 * (1/5 * 1/5) -1 = 1.192093e-07
5^2 * (1/5 * 1/5) -1 = 2.220446e-16

(for single & double precision respectively) and what this has to do with the fact that single precision has a 23 bit mantissa and double 51?
Ok, I'm not sure that I would bother first-years with this, but second definitely.

> **Comments:**
> **username_14**: I think you meant to do `- 1` somewhere.  
> **username_13**: Oops. Yes. Thanks.  

---

### Answer by username_11 on 2020-03-08. Score: 0

Binary math is an imperative to understand automation. 36 years on the job with 14 years on podium. Especially today where the the world is full of assumptions. All new employees I have had could not conceive how the physical inputs and outputs work in relationships to the masterful programming they developed.

> **Comments:**
> **username_12**: Welcome to [cseducators.se].  I have a few requests for edits to your answer.  First, what is "on podium"?  Also, could you expand on your second sentence?  

---

