- Feature Articles
- CodeSOD
- Error'd
-
Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
Pretty stupid to show us the "correct" version first. That's the real WTF. And also, the O / 0 difference is trivial and easy to spot just scanning the code.
Admin
O versus 0 (zero) was the first thing I looked for. I still slashed my zeros for a couple decades after it became unnecessary.
Admin
It was the only thing that COULD have been wrong in that code.
But yeah, it happens. There's a reason why you don't use upper-case o or lower-case L as variable names.
Admin
As a programmer who worked for a company that developed a version of BASIC, the difference between 0 and O was hard to see on a glass tty. Back in those days i had a problem with " " where I meant to have a space but it was actually a tab character in a column that was a multiple of 8. I was just learning 'vi' and now I make use of the :set list command. :-)
Admin
Reminds me of college. I was a T/A for a programming class, and one of my students brought in some code for help. "I don't understand it," he said, "it's too short to have any bugs in it!" I find myself saying that all the time...
Admin
Some errors are hard to spot if you've never seen them before, like this one:
if (x = 0) { \* Whyyyy doesn't it execute this code. *\ }. That one got so many that some courses taught the students to put the constant first in the comparison becauseif (0 = x)would produce a compile-time error, preventing the bug. Some newer languages will either warn you or straight up fail to compile but in C and C++ never failed to provide interesting ways to shoot ourselves in the foot.Admin
I look forward to seeing how you do on your second rodeo, sir.
Admin
I have to admit that I totally didn't see anything like that coming, completely not at all.
And now that you're all back from finding how many floors below you the sarcasm dripping off your screens from the sentence above managed to eat its way through (ref: Alien), I'd like to apologise.
Admin
That's evil.
I remember creating batch files named chr(255) .bat somewhere in the path on people's PC's and putting them in the autoexec.bat (you didn't need to say it's a batch file IIRC). It showed up as an empty line with invisible content. It would run anything that was in my batch file (fun irritating stuff, you know), and it would only stop running on boot-up if they completely replaced their autoexec.bat with a new one or deleted all empty lines. Very few peeps would think to inspect a text file with a hex editor... Fun times.
Admin
This reader, the syntactic effort putting a subordinate clause in a subordinate clause requires appreciating admits to being somewhat surprised too. I thought the problem would be that FOR I = 1 TO 0 (zero, that is) runs once in some dialects.
Didn't need no complex test, Nobody worried about REST, Gee our PET 2001 was the best, Those were the days
Admin
It's hard for me to believe that, blurry CRTs or not, this problem would hang up "an entire computer science department." Like just about everyone else, I assumed that was the issue as I was reading the corrected code. Nobody thought to say to his peer "I totally believe that you typed O there but can you humor me and replace it with an O and see if it works?"
Admin
In that era, many CRT monitors and TTY/teletype terminals were only UPPERCASE, such as the Data General terminals I used in high school. Not much variety in fonts. We had a line-printer and one or two terminals that could show us lower case characters. We only worked in that line-numbered BASIC so we did learn to hash or zero, and reading them on paper or screen was something we noticed. If I recall correctly, the output on the teletype was also slanted a bit to the top-right. Not to indicate italics, but just for readability. Any of this was at least 5 years before the first time I saw the Internet, Unix or anything about networking.
Admin
@Hanzito -
An "All in the Family" reference? We are a really old crowd here.
Admin
Plus back in those days many typewriters didn't have a 0 (zero) key, so you substituted an O (oh) instead.
Admin
Thank you for the reference to Dartmouth Oversimplified Programming Experiment. I had never heard of it before, but it makes sense that they were experimenting with languages that led to BASIC.
See https://en.wikipedia.org/wiki/Dartmouth_Oversimplified_Programming_Experiment.
Admin
To be honest, the first thing I checked on the original snippet was that the O was an O and not a 0.
I leaned to program on Altair 4k BASIC, so this is kind of a natural thing for me.
Admin
That is what the submitter claimed, and my reason for believing it is that the code exists in a broader context. When you whittle down to the lines that are actually the problem, it's easy to spot. But when you've got hundreds of other lines to filter through, when you're getting dropped in by a junior/student dev who's like "It doesn't work and I can't figure it out," I can 100% see how that "O" hides out for awhile.
I've seen similar things happen with missing semicolons, though maybe not a "whole department".
Admin
In the early '80s, had a friend who was doing some outside-of-class work in Fortran77 and suddenly started seeing divide by zero errors. Traced it down to a line that contained "/4". Took him a fair bit of time to realize that in trying to debug somewhere else in the routine he had inserted "4 = 0". As Remy said, easy to spot in isolation, harder to spot in the midst of a big chunk of code with dodgy display fonts.
Admin
So we're back to variable names frist?
Admin
Back in the day, I worked on Vermont Views. It had a macro to make a borderless window, which was unfortunately called "BDR_P0". And I was the hero who figured out that it was BDR_P(Zero), not BDR_P(cap O). Good times.
Admin
Keep on mind that in that era, it was not uncommon to have just a single casing, typically UPPER case. I do recall some systems having a slash inside of zeros to disambiguate.
Admin
This is why I use a font specifically designed for coders -- with a proper slashed-zero and serifs to make 'one' and 'lower-case L" easily distinguishable.
Admin
I wonder how anyone making a Danish-based programming language would've coped, since they'd need O, 0 and Ø.
Admin
Now; it /was/ a long time ago (in a galaxy far, far away), i.e. about 1977, and memory fades so I could be misremembering, but I'm convinced that in the first implementation of BASIC I used on a SWTPC 6800 O (letter) and 0 (number) could, in some circumstances, be used interchangeably. Oh what larks.
Admin
My first typewriters lacked 0 and 1 keys, so one had to use capital O and lower-case l to write numbers. I seem to remember early programming manuals reminding people to use the number keys instead of the letter keys, but I couldn't find an example. I do remember the "joy" of moving back and forth between a PLATO® keyboard (with the 0 key to the left of the 1 key) and a normal computer keyboard (with the 0 to the right of the 9 key).
Admin
I did work experience at the local town council and found a lot of entries in their system where the number 0 had been placed instead of the letter o. I also recall helping someone writing a problem in BASIC for the Apple II. They were getting the same random result every time. I realised they'd set the seed value to 0.
Admin
Which is why a lot of us chose to do '0 = x' in the if statement.
Admin
It's why I use the DOS VGA font as my text editor and terminal fonts. Those VGA fonts were made to make common letter pairs distinct and I prefer it much over the other "terminal" fonts commonly shipped. They were originally made for CRTs so they retained their distinctiveness.
(www.int10h.org is where I got mine).
Admin
in fortran it was possible to change the value of literal 4 to 0 by a function call, something like this:
C At this point the program will crash
Subroutine wibble(i) i=0 return
NB I don't remember the exact syntax cos this was fortran iv. and 45 years ago.
Addendum 2025-10-29 18:03: sigh lets try again
Admin
I can accept that some FORTRAN compilers did as you say. However, my experience with VAX FORTRAN back in 1985 was different; that code wouldn't crash because each instance of a hard-coded number was a separate memory location. You have two "4"s so that would have been two places, and only the first would be set to zero, leave the "a=a/4" to work correctly.
But the passing mechanism was indeed "by reference" even for constants, so code like this would crash on a VAX:
would result in
Admin
People have mentioned uppercase terminals. But I recall that they also had slashed zero characters.
Admin
When I was, ahem, "learning" coding, which is to say copying someone else's code and mutilating it till it did what I wanted, I eventually graduated to writing some short snippets by myself. Being nearsighted, I confused a period for a comma in several expressions, and you can guess what happened next.
Admin
Now go ahead and 's/;/;/g' all over your C / C++ / C# / Java / JS codebase. Nobody will notice!
Admin
One of the reasons why later type in magazines had a checksummer tool that would display a check sum (old fangled word for hash) when you entered a line of code.
Admin
The problem could have been avoided by banning the 0.
You can always replace 0 by 48398 - 48398 or something like that.
Admin
I remember running into something (I don't remember what) that slashed the letter O instead of slashing zeroes. I was baffled that one would so such a thing.
Admin
We used to say the big advantage of Basic was that any fool could sit down at a keyboard and write a program.
The big disadvantage was that he did.
Admin
Back in the day there were as many conventions about how to distinguish between O & 0 as there were manufacturers and models of screens and printers. Yes, slashing the zero, and making the O rounder was the single most common. Might even have been the majority solution. But it was far far short of universal.
At one shop I recall, the screens' font made the O quite round and put a dot in the center of it. While the printers, from a different manufacturer, put a sorta-dash through the zero, making it resemble a theta: Θ.
Good luck keeping that straight when switching back and forth between screen and printout.
Admin
This is often used for amateur radio callsigns in publications (magazines): DLØZZZ instead of DL0ZZZ. For hand-written callsigns, for example on QSL cards, it's also very common to allow the automatic sorters to work propery, e. g., DL7ØØBORG (celebrating 700 years of the Borg occupation).
Admin
You took that too literally. We need a <sarcasm> tag!
Admin
Not sure why you're assuming they all did. They definitely did not.
Admin
IBM for the win! Also, I'm looking at my "yellow card" (System /370 Reference Summary, Fifth Edition, October 1981) and I assure you that the character shown for 0x30 --- the digit zero --- looks exactly the same as that for 0xD6 --- the capital letter O.
Addendum 2025-10-30 10:37: EBCDIC, of course; and I typoed 0x30 for the correct 0xF0. Sorry.
Edit Admin
Why do you think they all do now?
Admin
A colleague had been staring with increasing frustration and ever-louder expletives at a DCL script that was throwing an error he could not figure out.
I looked over his shoulder and replaced a start-of-line S with a dollar sign. Job done.