In JavaLanguage:
public class Buggy { public static voi main( String [] args ) { System.out.println( 0.1 ); } }There's a 'd' missing from 'void'. So how many bugs are in this Java code??
In GNU SmallTalk:
0.1 printIn SmallTalk 80:
0.1 (printIt)In PythonLanguage:
print repr(0.1)or better yet
bExBase:
? 1/0 (Similar to "print(1.0 / 0.0);" in C-like langs)
Is the referred-to "bug" the fact that 0.1 is not exactly representable in IEEE 754 floating point? One could argue that the program is behaving correctly...
There's an old programming proverb to the effect that "all programs have at least one bug and at least one redundant instruction". Iteratively, then, all programs can be reduced to a single instruction that doesn't work.
abort() ???
A friend has a story that illustrates the truth of this. Somewhere in an IBM mainframe OS (I don't know which one), there was a module that contained but a single instruction (it was a privilege-switching module). It was like that for several years. Eventually, a circumstance was discovered when it didn't work, and a bug report was raised. So the one instruction program did indeed have a bug. Apparently it's 13 instructions now.
From the context, there's every reason to think that this was a hardware bug, and that the extra dozen instructions were a work-around, not a fix for a software bug.
There's another IBM mainframe story, to the effect that someone wanted to write a program that did nothing, so they wrote one that said
BR 15Then someone pointed out that it should really say
BR 14(because programs are usually called using a BALR 14,15). Then someone else pointed out that the return code (in register 15) was unpredictable, so it would be better to write
SR 15,15 BR 142 statements - 2 bugs!